#Who favor in-group politicians?

#In-group voting in France, Germany and the Netherlands 
#and the challenges to the descriptive and substantive representation of Muslims

#Van Oosten 2023 - OSF

#https://doi.org/10.31219/osf.io/rkejd

setwd(" ")

library(haven)
library(patchwork)
library(cowplot)
library(gridGraphics)
library(GGally)
library(coefplot)
library(broom)
library(dplyr)
library(ellipsis)
library(tidyverse) 
library(tidyr)
library(magrittr)
library(stringr)
library(forcats)
library(ggplot2)
library(jtools)
library(sjPlot)
library(sjmisc)
library(sjlabelled)
library(miceadds)
library(vtable)
library(gt)
library(nnet)

FR <- haven::read_sav("DataFR_EMMAVID_vanOosten_etal_2024.sav")
DE <- haven::read_sav("DataDE_EMMAVID_vanOosten_etal_2024.sav")
NL <- haven::read_sav("DataNL_EMMAVID_vanOosten_etal_2024.sav")

#-------------------------#
#--- control variables ---#
#-------------------------#

#FR GEN
FR <- FR %>% mutate(Woman = case_when(V640 == 1 ~ 0,
                                      V640 == 2 ~ 1))
#FR AGE
FR$AGE <- 2020 - FR$V650
FR$Age <- ((FR$AGE)/100)
#FR EDU
FR$EDU <- FR$V680
FR  <- mutate(FR, EDU = ifelse(is.na(EDU), 10, EDU))
FR <- FR %>% mutate(Education = case_when(FR$EDU == 1 ~ 0,
                                          FR$EDU == 2 ~ (1/8),
                                          FR$EDU == 3 ~ (2/8),
                                          FR$EDU == 4 ~ (3/8),
                                          FR$EDU == 5 ~ (4/8),
                                          FR$EDU == 6 ~ (5/8),
                                          FR$EDU == 7 ~ (6/8),
                                          FR$EDU == 8 ~ (7/8),
                                          FR$EDU == 9 ~ 1,
                                          FR$EDU == 10 ~ 0.5))

FR$EDU

#DE GEN
DE <- DE %>% mutate(Woman = case_when(V640 == 1 ~ 0,
                                      V640 == 2 ~ 1))
#DE AGE
DE$AGE <- 2020 - DE$V650
DE$Age <- ((DE$AGE)/100)
#DE EDU
DE$EDU <- DE$V680
DE  <- mutate(DE, EDU = ifelse(is.na(EDU), 10, EDU))
DE <- DE %>% mutate(Education = case_when(DE$EDU == 1 ~ 0,
                                          DE$EDU == 2 ~ (1/8),
                                          DE$EDU == 3 ~ (2/8),
                                          DE$EDU == 4 ~ (3/8),
                                          DE$EDU == 5 ~ (4/8),
                                          DE$EDU == 6 ~ (5/8),
                                          DE$EDU == 7 ~ (6/8),
                                          DE$EDU == 8 ~ (7/8),
                                          DE$EDU == 9 ~ 1,
                                          DE$EDU == 10 ~ 0.5))
#NL GEN
NL <- NL %>% mutate(Woman = case_when(GSL == 1 ~ 0,
                                      GSL == 2 ~ 1))
#NL AGE
NL$Age <- ((NL$LFT)/100)
#NL EDU
NL <- NL %>% mutate(Education = case_when(NL$OPL == 1 ~ 0,
                                          NL$OPL == 2 ~ (1/6),
                                          NL$OPL == 3 ~ (2/6),
                                          NL$OPL == 4 ~ (3/6),
                                          NL$OPL == 5 ~ (4/6),
                                          NL$OPL == 6 ~ (5/6),
                                          NL$OPL == 7 ~ 1,
                                          NL$OPL == 8 ~ 0.5))
FR$AGE2 <- (FR$Age*FR$Age)
DE$AGE2 <- (DE$Age*DE$Age)
NL$AGE2 <- (NL$Age*NL$Age)

#---------------#
#--- weights ---#
#---------------#

FR <- FR %>% mutate(catrace = case_when(V50030 == 1 & V50040 == 1 ~ "Turkey",
                                        V50030 == 2 & V50040 == 2 ~ "North-Africa",
                                        V50030 == 3 & V50040 == 3 ~ "Sub-Saharan Africa",
                                        V50030 == 4 & V50040 == 4 ~ "France",
                                        V50030 == 5 & V50040 == 5 ~ "Other",
                                        
                                        V50030 == 1 & V50040 == 4 ~ "Turkey",
                                        V50030 == 4 & V50040 == 1 ~ "Turkey",
                                        V50030 == 1 & V50040 == 5 ~ "Turkey",
                                        V50030 == 5 & V50040 == 1 ~ "Turkey",
                                        
                                        V50030 == 2 & V50040 == 4 ~ "North-Africa",
                                        V50030 == 4 & V50040 == 2 ~ "North-Africa",
                                        V50030 == 2 & V50040 == 5 ~ "North-Africa",
                                        V50030 == 5 & V50040 == 2 ~ "North-Africa",
                                        
                                        V50030 == 3 & V50040 == 4 ~ "Sub-Saharan Africa",
                                        V50030 == 4 & V50040 == 3 ~ "Sub-Saharan Africa",
                                        V50030 == 3 & V50040 == 5 ~ "Sub-Saharan Africa",
                                        V50030 == 5 & V50040 == 3 ~ "Sub-Saharan Africa",
                                        
                                        V50030 == 1 & V50040 == 2 ~ "Turkey",
                                        V50030 == 2 & V50040 == 1 ~ "North-Africa",
                                        V50030 == 1 & V50040 == 3 ~ "Turkey",
                                        V50030 == 3 & V50040 == 1 ~ "Sub-Saharan Africa",
                                        V50030 == 2 & V50040 == 3 ~ "North-Africa",
                                        V50030 == 3 & V50040 == 2 ~ "Sub-Saharan Africa",
                                        
                                        V50030 == 4 & V50040 == 5 ~ "France",
                                        V50030 == 5 & V50040 == 4 ~ "France"))
DE <- DE %>% mutate(catrace = case_when(V50030 == 1 & V50040 == 1 ~ "Turkey",
                                           V50030 == 2 & V50040 == 2 ~ "FSU",
                                           V50030 == 3 & V50040 == 3 ~ "German",
                                           V50030 == 4 & V50040 == 4 ~ "Other",
                                           
                                           V50030 == 1 & V50040 == 3 ~ "Turkey",
                                           V50030 == 3 & V50040 == 1 ~ "Turkey",
                                           V50030 == 1 & V50040 == 4 ~ "Turkey",
                                           V50030 == 4 & V50040 == 1 ~ "Turkey",
                                           
                                           V50030 == 2 & V50040 == 3 ~ "FSU",
                                           V50030 == 3 & V50040 == 2 ~ "FSU",
                                           V50030 == 2 & V50040 == 4 ~ "FSU",
                                           V50030 == 4 & V50040 == 2 ~ "FSU",
                                           
                                           V50030 == 1 & V50040 == 2 ~ "Turkey",
                                           V50030 == 2 & V50040 == 1 ~ "FSU",
                                           V50030 == 3 & V50040 == 4 ~ "German",
                                           V50030 == 4 & V50040 == 3 ~ "German"))
NL <- NL %>% mutate(catrace = case_when(V50030 == 1 & V50040 == 1 ~ "Turkey",
                                           V50030 == 2 & V50040 == 2 ~ "Morocco",
                                           V50030 == 3 & V50040 == 3 ~ "Surinam",
                                           V50030 == 4 & V50040 == 4 ~ "Dutch",
                                           V50030 == 5 & V50040 == 5 ~ "Other",
                                           
                                           V50030 == 1 & V50040 == 4 ~ "Turkey",
                                           V50030 == 4 & V50040 == 1 ~ "Turkey",
                                           V50030 == 1 & V50040 == 5 ~ "Turkey",
                                           V50030 == 5 & V50040 == 1 ~ "Turkey",
                                           
                                           V50030 == 2 & V50040 == 4 ~ "Morocco",
                                           V50030 == 4 & V50040 == 2 ~ "Morocco",
                                           V50030 == 2 & V50040 == 5 ~ "Morocco",
                                           V50030 == 5 & V50040 == 2 ~ "Morocco",
                                           
                                           V50030 == 3 & V50040 == 4 ~ "Surinam",
                                           V50030 == 4 & V50040 == 3 ~ "Surinam",
                                           V50030 == 3 & V50040 == 5 ~ "Surinam",
                                           V50030 == 5 & V50040 == 3 ~ "Surinam",
                                           
                                           V50030 == 1 & V50040 == 2 ~ "Turkey",
                                           V50030 == 2 & V50040 == 1 ~ "Morocco",
                                           V50030 == 1 & V50040 == 3 ~ "Turkey",
                                           V50030 == 3 & V50040 == 1 ~ "Surinam",
                                           V50030 == 2 & V50040 == 3 ~ "Morocco",
                                           V50030 == 3 & V50040 == 2 ~ "Surinam",
                                           
                                           V50030 == 4 & V50040 == 5 ~ "Dutch",
                                           V50030 == 5 & V50040 == 4 ~ "Dutch"))

#w8
FR <- FR %>% mutate(w8eth = case_when(FR$catrace == "France" ~ 2.072058,
                                      FR$catrace == "North-Africa" ~ 0.1111513,
                                      FR$catrace == "Sub-Saharan Africa" ~ 0.07401234,
                                      FR$catrace == "Turkey" ~ 0.05011495,
                                      FR$catrace == "Other" ~ 0.449313))
FR  <- mutate(FR, w8eth = ifelse(is.na(w8eth), 1, w8eth))
#DE
DE <- DE %>% mutate(w8eth = case_when(DE$catrace == "German" ~ (59466174/69488809)/(346/954),
                                      DE$catrace == "FSU" ~ (598230/69488809)/(266/954),
                                      DE$catrace == "Turkey" ~ (1472430/69488809)/(198/954),
                                      DE$catrace == "Other" ~ (7951975/69488809)/(144/954)))
DE  <- mutate(DE, w8eth = ifelse(is.na(w8eth), 1, w8eth))
#NL
NL <- NL %>% mutate(w8eth = case_when(NL$catrace == "Dutch" ~ 2.346212,
                                      NL$catrace == "Morocco" ~ 0.1340415,
                                      NL$catrace == "Turkey" ~ 0.1026367,
                                      NL$catrace == "Surinam" ~ 0.07831423,
                                      NL$catrace == "Other" ~ 1))
NL  <- mutate(NL, w8eth = ifelse(is.na(w8eth), 1, w8eth))

#---------------------#
#-- MERGE FR DE NL ---#
#---------------------#

#FR
mergeFR <- as_tibble(FR$INTNR)  
names(mergeFR) <- "INTNR"
mergeFR$cntry <- "France"

mergeFR$V160_1 <- FR$V160_1
mergeFR$V160_3 <- FR$V160_3
mergeFR$V160_5 <- FR$V160_5
mergeFR$V160_7 <- FR$V160_7
mergeFR$V160_9 <- FR$V160_9
mergeFR$V160_11 <- FR$V160_11
mergeFR$V160_13 <- FR$V160_13
mergeFR$V160_15 <- FR$V160_15
mergeFR$V80_2 <- FR$V80_2
mergeFR$V80_4 <- FR$V80_4
mergeFR$V80_6 <- FR$V80_6
mergeFR$V80_8 <- FR$V80_8
mergeFR$V80_10 <- FR$V80_10
mergeFR$V80_12 <- FR$V80_12
mergeFR$V80_14 <- FR$V80_14
mergeFR$V80_16 <- FR$V80_16

mergeFR$V54001 <- FR$V54001
mergeFR$V54002 <- FR$V54002
mergeFR$V54003 <- FR$V54003
mergeFR$V54005 <- FR$V54005
mergeFR$V469_1 <- FR$V469_1
mergeFR$V469_2 <- FR$V469_2

mergeFR$V331_1 <- FR$V331_1
mergeFR$V331_2 <- FR$V331_2
mergeFR$V332_1 <- FR$V332_1
mergeFR$V332_2 <- FR$V332_2
mergeFR$V333_1 <- FR$V333_1
mergeFR$V333_2 <- FR$V333_2
mergeFR$V334_1 <- FR$V334_1
mergeFR$V334_2 <- FR$V334_2
mergeFR$V335_2 <- FR$V335_2
mergeFR$V335_1 <- FR$V335_1
mergeFR$V335_2 <- FR$V335_2
mergeFR$V336_1 <- FR$V336_1
mergeFR$V336_2 <- FR$V336_2
mergeFR$V337_1 <- FR$V337_1
mergeFR$V337_2 <- FR$V337_2
mergeFR$V338_1 <- FR$V338_1
mergeFR$V338_2 <- FR$V338_2

mergeFR$V380 <- FR$V380
mergeFR$V410 <- FR$V410
mergeFR$V440 <- FR$V440
mergeFR$V580 <- FR$V580
mergeFR$V590 <- FR$V590
mergeFR$V600 <- FR$V600
mergeFR$V610 <- FR$V610
mergeFR$V619_1 <- FR$V619_1
mergeFR$V619_2 <- FR$V619_2
mergeFR$V619_3 <- FR$V619_3
mergeFR$V619_4 <- FR$V619_4
mergeFR$V5591_1 <- FR$V5591_1
mergeFR$V5691_1 <- FR$V5691_1

mergeFR$w8eth <- FR$w8eth
mergeFR$Age <- FR$Age
mergeFR$AGE2 <- FR$AGE2
mergeFR$Education <- FR$Education
mergeFR$Woman <- FR$Woman
mergeFR$catrace <- FR$catrace

mergeFR$idprofnogen_1 <- FR$V40_3
mergeFR$idprofnogen_2 <- FR$V40_4
mergeFR$idprofnogen_3 <- FR$V40_5
mergeFR$idprofnogen_4 <- FR$V40_6
mergeFR$idprofnogen_5 <- FR$V40_7
mergeFR$idprofnogen_6 <- FR$V40_8

mergeFR$idprofgen_1 <- FR$V10_3
mergeFR$idprofgen_2 <- FR$V10_4
mergeFR$idprofgen_3 <- FR$V10_5
mergeFR$idprofgen_4 <- FR$V10_6
mergeFR$idprofgen_5 <- FR$V10_7
mergeFR$idprofgen_6 <- FR$V10_8

mergeFR$idprofpp_1 <- FR$V2001
mergeFR$idprofpp_2 <- FR$V2002
mergeFR$idprofpp_3 <- FR$V2003
mergeFR$idprofpp_4 <- FR$V2004
mergeFR$idprofpp_5 <- FR$V2005
mergeFR$idprofpp_6 <- FR$V2006

mergeFR$DVrep_1 <- FR$V359_1
mergeFR$DVrep_2 <- FR$V369_1
mergeFR$DVrep_3 <- FR$V389_1
mergeFR$DVrep_4 <- FR$V399_1
mergeFR$DVrep_5 <- FR$V419_1
mergeFR$DVrep_6 <- FR$V429_1

mergeFR$DVtru_1 <- FR$V359_2
mergeFR$DVtru_2 <- FR$V369_2
mergeFR$DVtru_3 <- FR$V389_2
mergeFR$DVtru_4 <- FR$V399_2
mergeFR$DVtru_5 <- FR$V419_2
mergeFR$DVtru_6 <- FR$V429_2

mergeFR$DVcom_1 <- FR$V359_3
mergeFR$DVcom_2 <- FR$V369_3
mergeFR$DVcom_3 <- FR$V389_3
mergeFR$DVcom_4 <- FR$V399_3
mergeFR$DVcom_5 <- FR$V419_3
mergeFR$DVcom_6 <- FR$V429_3

#DE
mergeDE <- as_tibble(DE$INTNR)  
names(mergeDE) <- "INTNR"
mergeDE$cntry <- "Germany"

mergeDE$V160_1 <- DE$V160_1
mergeDE$V160_3 <- DE$V160_3
mergeDE$V160_5 <- DE$V160_5
mergeDE$V160_7 <- DE$V160_7
mergeDE$V160_9 <- DE$V160_9
mergeDE$V160_11 <- DE$V160_11
mergeDE$V160_13 <- DE$V160_13
mergeDE$V160_15 <- DE$V160_15
mergeDE$V80_2 <- DE$V80_2
mergeDE$V80_4 <- DE$V80_4
mergeDE$V80_6 <- DE$V80_6
mergeDE$V80_8 <- DE$V80_8
mergeDE$V80_10 <- DE$V80_10
mergeDE$V80_12 <- DE$V80_12
mergeDE$V80_14 <- DE$V80_14
mergeDE$V80_16 <- DE$V80_16

mergeDE$V54001 <- DE$V54001
mergeDE$V54002 <- DE$V54002
mergeDE$V54003 <- DE$V54003
mergeDE$V54005 <- DE$V54005
mergeDE$V469_1 <- DE$V469_1
mergeDE$V469_2 <- DE$V469_2

mergeDE$V331_1 <- DE$V331_1
mergeDE$V331_2 <- DE$V331_2
mergeDE$V332_1 <- DE$V332_1
mergeDE$V332_2 <- DE$V332_2
mergeDE$V333_1 <- DE$V333_1
mergeDE$V333_2 <- DE$V333_2
mergeDE$V334_1 <- DE$V334_1
mergeDE$V334_2 <- DE$V334_2
mergeDE$V335_2 <- DE$V335_2
mergeDE$V335_1 <- DE$V335_1
mergeDE$V335_2 <- DE$V335_2
mergeDE$V336_1 <- DE$V336_1
mergeDE$V336_2 <- DE$V336_2
mergeDE$V337_1 <- DE$V337_1
mergeDE$V337_2 <- DE$V337_2
mergeDE$V338_1 <- DE$V338_1
mergeDE$V338_2 <- DE$V338_2

mergeDE$V380 <- DE$V380
mergeDE$V410 <- DE$V410
mergeDE$V440 <- DE$V440
mergeDE$V580 <- DE$V580
mergeDE$V590 <- DE$V590
mergeDE$V600 <- DE$V600
mergeDE$V610 <- DE$V610
mergeDE$V619_1 <- DE$V619_1
mergeDE$V619_2 <- DE$V619_2
mergeDE$V619_3 <- DE$V619_3
mergeDE$V619_4 <- DE$V619_4
mergeDE$V5591_1 <- DE$V5591_1
mergeDE$V5691_1 <- DE$V5691_1

mergeDE$w8eth <- DE$w8eth
mergeDE$Age <- DE$Age
mergeDE$AGE2 <- DE$AGE2
mergeDE$Education <- DE$Education
mergeDE$Woman <- DE$Woman
mergeDE$catrace <- DE$catrace

mergeDE$idprofnogen_1 <- DE$V40_3
mergeDE$idprofnogen_2 <- DE$V40_4
mergeDE$idprofnogen_3 <- DE$V40_5
mergeDE$idprofnogen_4 <- DE$V40_6
mergeDE$idprofnogen_5 <- DE$V40_7
mergeDE$idprofnogen_6 <- DE$V40_8

mergeDE$idprofgen_1 <- DE$V10_3
mergeDE$idprofgen_2 <- DE$V10_4
mergeDE$idprofgen_3 <- DE$V10_5
mergeDE$idprofgen_4 <- DE$V10_6
mergeDE$idprofgen_5 <- DE$V10_7
mergeDE$idprofgen_6 <- DE$V10_8

mergeDE$idprofpp_1 <- DE$V2001
mergeDE$idprofpp_2 <- DE$V2002
mergeDE$idprofpp_3 <- DE$V2003
mergeDE$idprofpp_4 <- DE$V2004
mergeDE$idprofpp_5 <- DE$V2005
mergeDE$idprofpp_6 <- DE$V2006

mergeDE$DVrep_1 <- DE$V359_1
mergeDE$DVrep_2 <- DE$V369_1
mergeDE$DVrep_3 <- DE$V389_1
mergeDE$DVrep_4 <- DE$V399_1
mergeDE$DVrep_5 <- DE$V419_1
mergeDE$DVrep_6 <- DE$V429_1

mergeDE$DVtru_1 <- DE$V359_2
mergeDE$DVtru_2 <- DE$V369_2
mergeDE$DVtru_3 <- DE$V389_2
mergeDE$DVtru_4 <- DE$V399_2
mergeDE$DVtru_5 <- DE$V419_2
mergeDE$DVtru_6 <- DE$V429_2

mergeDE$DVcom_1 <- DE$V359_3
mergeDE$DVcom_2 <- DE$V369_3
mergeDE$DVcom_3 <- DE$V389_3
mergeDE$DVcom_4 <- DE$V399_3
mergeDE$DVcom_5 <- DE$V419_3
mergeDE$DVcom_6 <- DE$V429_3

#NL
mergeNL <- as_tibble(NL$INTNR)  
names(mergeNL) <- "INTNR"
mergeNL$cntry <- "Netherlands"

mergeNL$V160_1 <- NL$V160_1
mergeNL$V160_3 <- NL$V160_3
mergeNL$V160_5 <- NL$V160_5
mergeNL$V160_7 <- NL$V160_7
mergeNL$V160_9 <- NL$V160_9
mergeNL$V160_11 <- NL$V160_11
mergeNL$V160_13 <- NL$V160_13
mergeNL$V160_15 <- NL$V160_15
mergeNL$V80_2 <- NL$V80_2
mergeNL$V80_4 <- NL$V80_4
mergeNL$V80_6 <- NL$V80_6
mergeNL$V80_8 <- NL$V80_8
mergeNL$V80_10 <- NL$V80_10
mergeNL$V80_12 <- NL$V80_12
mergeNL$V80_14 <- NL$V80_14
mergeNL$V80_16 <- NL$V80_16

mergeNL$V54001 <- NL$V54001
mergeNL$V54003 <- NL$V54003
mergeNL$V54002 <- NL$V54002
mergeNL$V54005 <- NL$V54005
mergeNL$V469_1 <- NL$V469_1
mergeNL$V469_2 <- NL$V469_2

mergeNL$V331_1 <- NL$V331_1
mergeNL$V331_2 <- NL$V331_2
mergeNL$V332_1 <- NL$V332_1
mergeNL$V332_2 <- NL$V332_2
mergeNL$V333_1 <- NL$V333_1
mergeNL$V333_2 <- NL$V333_2
mergeNL$V334_1 <- NL$V334_1
mergeNL$V334_2 <- NL$V334_2
mergeNL$V335_2 <- NL$V335_2
mergeNL$V335_1 <- NL$V335_1
mergeNL$V335_2 <- NL$V335_2
mergeNL$V336_1 <- NL$V336_1
mergeNL$V336_2 <- NL$V336_2
mergeNL$V337_1 <- NL$V337_1
mergeNL$V337_2 <- NL$V337_2
mergeNL$V338_1 <- NL$V338_1
mergeNL$V338_2 <- NL$V338_2

mergeNL$V380 <- NL$V380
mergeNL$V410 <- NL$V410
mergeNL$V440 <- NL$V440
mergeNL$V580 <- NL$V580
mergeNL$V590 <- NL$V590
mergeNL$V600 <- NL$V600
mergeNL$V610 <- NL$V610
mergeNL$V619_1 <- NL$V619_1
mergeNL$V619_2 <- NL$V619_2
mergeNL$V619_3 <- NL$V619_3
mergeNL$V619_4 <- NL$V619_4
mergeNL$V5591_1 <- NL$V5591_1
mergeNL$V5691_1 <- NL$V5691_1

mergeNL$w8eth <- NL$w8eth
mergeNL$Age <- NL$Age
mergeNL$AGE2 <- NL$AGE2
mergeNL$Education <- NL$Education
mergeNL$Woman <- NL$Woman
mergeNL$catrace <- NL$catrace

mergeNL$idprofnogen_1 <- NL$V40_3
mergeNL$idprofnogen_2 <- NL$V40_4
mergeNL$idprofnogen_3 <- NL$V40_5
mergeNL$idprofnogen_4 <- NL$V40_6
mergeNL$idprofnogen_5 <- NL$V40_7
mergeNL$idprofnogen_6 <- NL$V40_8

mergeNL$idprofgen_1 <- NL$V10_3
mergeNL$idprofgen_2 <- NL$V10_4
mergeNL$idprofgen_3 <- NL$V10_5
mergeNL$idprofgen_4 <- NL$V10_6
mergeNL$idprofgen_5 <- NL$V10_7
mergeNL$idprofgen_6 <- NL$V10_8

mergeNL$idprofpp_1 <- NL$V2001
mergeNL$idprofpp_2 <- NL$V2002
mergeNL$idprofpp_3 <- NL$V2003
mergeNL$idprofpp_4 <- NL$V2004
mergeNL$idprofpp_5 <- NL$V2005
mergeNL$idprofpp_6 <- NL$V2006

mergeNL$DVrep_1 <- NL$V359_1
mergeNL$DVrep_2 <- NL$V369_1
mergeNL$DVrep_3 <- NL$V389_1
mergeNL$DVrep_4 <- NL$V399_1
mergeNL$DVrep_5 <- NL$V419_1
mergeNL$DVrep_6 <- NL$V429_1

mergeNL$DVtru_1 <- NL$V359_2
mergeNL$DVtru_2 <- NL$V369_2
mergeNL$DVtru_3 <- NL$V389_2
mergeNL$DVtru_4 <- NL$V399_2
mergeNL$DVtru_5 <- NL$V419_2
mergeNL$DVtru_6 <- NL$V429_2

mergeNL$DVcom_1 <- NL$V359_3
mergeNL$DVcom_2 <- NL$V369_3
mergeNL$DVcom_3 <- NL$V389_3
mergeNL$DVcom_4 <- NL$V399_3
mergeNL$DVcom_5 <- NL$V419_3
mergeNL$DVcom_6 <- NL$V429_3

#the actual merging
FGNfirst <- rbind(mergeFR, mergeDE, mergeNL)

#------------------------------------#
#--- policy positions respondents ---#
#------------------------------------#

#tax.rich.higher
FGNfirst <- FGNfirst %>% mutate(tax.rich.higher = case_when(V160_1 == 1 ~ 0,
                                                            V160_1 == 2 ~ 0.1,
                                                            V160_1 == 3 ~ 0.2,
                                                            V160_1 == 4 ~ 0.3,
                                                            V160_1 == 5 ~ 0.4,
                                                            V160_1 == 6 ~ 0.5,
                                                            V160_1 == 7 ~ 0.6,
                                                            V160_1 == 8 ~ 0.7,
                                                            V160_1 == 9 ~ 0.8,
                                                            V160_1 == 10 ~ 0.9,
                                                            V160_1 == 11 ~ 1,
                                                            V80_2 == 1 ~ 1,
                                                            V80_2 == 2 ~ 0.9,
                                                            V80_2 == 3 ~ 0.8,
                                                            V80_2 == 4 ~ 0.7,
                                                            V80_2 == 5 ~ 0.6,
                                                            V80_2 == 6 ~ 0.5,
                                                            V80_2 == 7 ~ 0.4,
                                                            V80_2 == 8 ~ 0.3,
                                                            V80_2 == 9 ~ 0.2,
                                                            V80_2 == 10 ~ 0.1,
                                                            V80_2 == 11 ~ 0))

FGNfirst <- FGNfirst %>% mutate(tax.rich.higher.resp.agree = case_when(tax.rich.higher == 0.6 ~ 1,
                                                           tax.rich.higher == 0.7 ~ 1,
                                                           tax.rich.higher == 0.8 ~ 1,
                                                           tax.rich.higher == 0.9 ~ 1,
                                                           tax.rich.higher == 1 ~ 1,
                                                           tax.rich.higher == 0.0 ~ 0,
                                                           tax.rich.higher == 0.1 ~ 0,
                                                           tax.rich.higher == 0.2 ~ 0,
                                                           tax.rich.higher == 0.3 ~ 0,
                                                           tax.rich.higher == 0.4 ~ 0))
FGNfirst <- FGNfirst %>% mutate(tax.rich.higher.resp.disagree = case_when(tax.rich.higher == 0.6 ~ 0,
                                                              tax.rich.higher == 0.7 ~ 0,
                                                              tax.rich.higher == 0.8 ~ 0,
                                                              tax.rich.higher == 0.9 ~ 0,
                                                              tax.rich.higher == 1 ~ 0,
                                                              tax.rich.higher == 0.0 ~ 1,
                                                              tax.rich.higher == 0.1 ~ 1,
                                                              tax.rich.higher == 0.2 ~ 1,
                                                              tax.rich.higher == 0.3 ~ 1,
                                                              tax.rich.higher == 0.4 ~ 1))
FGNfirst <- FGNfirst %>% mutate(tax.rich.higher.resp.dk = case_when(tax.rich.higher == 0.5 ~ 1))
FGNfirst  <- mutate(FGNfirst, tax.rich.higher.resp.dk = ifelse(is.na(tax.rich.higher.resp.dk), 0, tax.rich.higher.resp.dk))

#raise.supp.unemp
FGNfirst <- FGNfirst %>% mutate(raise.supp.unemp = case_when(V160_3 == 1 ~ 0,
                                                 V160_3 == 2 ~ 0.1,
                                                 V160_3 == 3 ~ 0.2,
                                                 V160_3 == 4 ~ 0.3,
                                                 V160_3 == 5 ~ 0.4,
                                                 V160_3 == 6 ~ 0.5,
                                                 V160_3 == 7 ~ 0.6,
                                                 V160_3 == 8 ~ 0.7,
                                                 V160_3 == 9 ~ 0.8,
                                                 V160_3 == 10 ~ 0.9,
                                                 V160_3 == 11 ~ 1,
                                                 V80_4 == 1 ~ 1,
                                                 V80_4 == 2 ~ 0.9,
                                                 V80_4 == 3 ~ 0.8,
                                                 V80_4 == 4 ~ 0.7,
                                                 V80_4 == 5 ~ 0.6,
                                                 V80_4 == 6 ~ 0.5,
                                                 V80_4 == 7 ~ 0.4,
                                                 V80_4 == 8 ~ 0.3,
                                                 V80_4 == 9 ~ 0.2,
                                                 V80_4 == 10 ~ 0.1,
                                                 V80_4 == 11 ~ 0))

FGNfirst <- FGNfirst %>% mutate(raise.supp.unemp.resp.agree = case_when(raise.supp.unemp == 0.6 ~ 1,
                                                            raise.supp.unemp == 0.7 ~ 1,
                                                            raise.supp.unemp == 0.8 ~ 1,
                                                            raise.supp.unemp == 0.9 ~ 1,
                                                            raise.supp.unemp == 1 ~ 1,
                                                            raise.supp.unemp == 0.0 ~ 0,
                                                            raise.supp.unemp == 0.1 ~ 0,
                                                            raise.supp.unemp == 0.2 ~ 0,
                                                            raise.supp.unemp == 0.3 ~ 0,
                                                            raise.supp.unemp == 0.4 ~ 0))
FGNfirst <- FGNfirst %>% mutate(raise.supp.unemp.resp.disagree = case_when(raise.supp.unemp == 0.6 ~ 0,
                                                               raise.supp.unemp == 0.7 ~ 0,
                                                               raise.supp.unemp == 0.8 ~ 0,
                                                               raise.supp.unemp == 0.9 ~ 0,
                                                               raise.supp.unemp == 1 ~ 0,
                                                               raise.supp.unemp == 0.0 ~ 1,
                                                               raise.supp.unemp == 0.1 ~ 1,
                                                               raise.supp.unemp == 0.2 ~ 1,
                                                               raise.supp.unemp == 0.3 ~ 1,
                                                               raise.supp.unemp == 0.4 ~ 1))
FGNfirst <- FGNfirst %>% mutate(raise.supp.unemp.resp.dk = case_when(raise.supp.unemp == 0.5 ~ 1))
FGNfirst  <- mutate(FGNfirst, raise.supp.unemp.resp.dk = ifelse(is.na(raise.supp.unemp.resp.dk), 0, raise.supp.unemp.resp.dk))

#more.com.climcha
FGNfirst <- FGNfirst %>% mutate(more.com.climcha = case_when(V160_5 == 1 ~ 0.0,
                                                 V160_5 == 2 ~ 0.1,
                                                 V160_5 == 3 ~ 0.2,
                                                 V160_5 == 4 ~ 0.3,
                                                 V160_5 == 5 ~ 0.4,
                                                 V160_5 == 6 ~ 0.5,
                                                 V160_5 == 7 ~ 0.6,
                                                 V160_5 == 8 ~ 0.7,
                                                 V160_5 == 9 ~ 0.8,
                                                 V160_5 == 10 ~ 0.9,
                                                 V160_5 == 11 ~ 1,
                                                 V80_6 == 1 ~ 1,
                                                 V80_6 == 2 ~ 0.9,
                                                 V80_6 == 3 ~ 0.8,
                                                 V80_6 == 4 ~ 0.7,
                                                 V80_6 == 5 ~ 0.6,
                                                 V80_6 == 6 ~ 0.5,
                                                 V80_6 == 7 ~ 0.4,
                                                 V80_6 == 8 ~ 0.3,
                                                 V80_6 == 9 ~ 0.2,
                                                 V80_6 == 10 ~ 0.1,
                                                 V80_6 == 11 ~ 0.0))

FGNfirst <- FGNfirst %>% mutate(more.com.climcha.resp.agree = case_when(more.com.climcha == 0.6 ~ 1,
                                                            more.com.climcha == 0.7 ~ 1,
                                                            more.com.climcha == 0.8 ~ 1,
                                                            more.com.climcha == 0.9 ~ 1,
                                                            more.com.climcha == 1 ~ 1,
                                                            more.com.climcha == 0.0 ~ 0,
                                                            more.com.climcha == 0.1 ~ 0,
                                                            more.com.climcha == 0.2 ~ 0,
                                                            more.com.climcha == 0.3 ~ 0,
                                                            more.com.climcha == 0.4 ~ 0))
FGNfirst <- FGNfirst %>% mutate(more.com.climcha.resp.disagree = case_when(more.com.climcha == 0.6 ~ 0,
                                                               more.com.climcha == 0.7 ~ 0,
                                                               more.com.climcha == 0.8 ~ 0,
                                                               more.com.climcha == 0.9 ~ 0,
                                                               more.com.climcha == 1 ~ 0,
                                                               more.com.climcha == 0.0 ~ 1,
                                                               more.com.climcha == 0.1 ~ 1,
                                                               more.com.climcha == 0.2 ~ 1,
                                                               more.com.climcha == 0.3 ~ 1,
                                                               more.com.climcha == 0.4 ~ 1))
FGNfirst <- FGNfirst %>% mutate(more.com.climcha.resp.dk = case_when(more.com.climcha == 0.5 ~ 1))
FGNfirst  <- mutate(FGNfirst, more.com.climcha.resp.dk = ifelse(is.na(more.com.climcha.resp.dk), 0, more.com.climcha.resp.dk))

#raise.fuel.price
FGNfirst <- FGNfirst %>% mutate(raise.fuel.price = case_when(V160_7 == 1 ~ 0.0,
                                                 V160_7 == 2 ~ 0.1,
                                                 V160_7 == 3 ~ 0.2,
                                                 V160_7 == 4 ~ 0.3,
                                                 V160_7 == 5 ~ 0.4,
                                                 V160_7 == 6 ~ 0.5,
                                                 V160_7 == 7 ~ 0.6,
                                                 V160_7 == 8 ~ 0.7,
                                                 V160_7 == 9 ~ 0.8,
                                                 V160_7 == 10 ~ 0.9,
                                                 V160_7 == 11 ~ 1,
                                                 V80_8 == 1 ~ 1,
                                                 V80_8 == 2 ~ 0.9,
                                                 V80_8 == 3 ~ 0.8,
                                                 V80_8 == 4 ~ 0.7,
                                                 V80_8 == 5 ~ 0.6,
                                                 V80_8 == 6 ~ 0.5,
                                                 V80_8 == 7 ~ 0.4,
                                                 V80_8 == 8 ~ 0.3,
                                                 V80_8 == 9 ~ 0.2,
                                                 V80_8 == 10 ~ 0.1,
                                                 V80_8 == 11 ~ 0.0))
FGNfirst <- FGNfirst %>% mutate(raise.fuel.price.resp.agree = case_when(raise.fuel.price == 0.6 ~ 1,
                                                            raise.fuel.price == 0.7 ~ 1,
                                                            raise.fuel.price == 0.8 ~ 1,
                                                            raise.fuel.price == 0.9 ~ 1,
                                                            raise.fuel.price == 1 ~ 1,
                                                            raise.fuel.price == 0.0 ~ 0,
                                                            raise.fuel.price == 0.1 ~ 0,
                                                            raise.fuel.price == 0.2 ~ 0,
                                                            raise.fuel.price == 0.3 ~ 0,
                                                            raise.fuel.price == 0.4 ~ 0))
FGNfirst <- FGNfirst %>% mutate(raise.fuel.price.resp.disagree = case_when(raise.fuel.price == 0.6 ~ 0,
                                                               raise.fuel.price == 0.7 ~ 0,
                                                               raise.fuel.price == 0.8 ~ 0,
                                                               raise.fuel.price == 0.9 ~ 0,
                                                               raise.fuel.price == 1 ~ 0,
                                                               raise.fuel.price == 0.0 ~ 1,
                                                               raise.fuel.price == 0.1 ~ 1,
                                                               raise.fuel.price == 0.2 ~ 1,
                                                               raise.fuel.price == 0.3 ~ 1,
                                                               raise.fuel.price == 0.4 ~ 1))
FGNfirst <- FGNfirst %>% mutate(raise.fuel.price.resp.dk = case_when(raise.fuel.price == 0.5 ~ 1))
FGNfirst  <- mutate(FGNfirst, raise.fuel.price.resp.dk = ifelse(is.na(raise.fuel.price.resp.dk), 0, raise.fuel.price.resp.dk))

#immigrants.R.asset
FGNfirst <- FGNfirst %>% mutate(immigrants.R.asset = case_when(V160_9 == 1 ~ 0.0,
                                                   V160_9 == 2 ~ 0.1,
                                                   V160_9 == 3 ~ 0.2,
                                                   V160_9 == 4 ~ 0.3,
                                                   V160_9 == 5 ~ 0.4,
                                                   V160_9 == 6 ~ 0.5,
                                                   V160_9 == 7 ~ 0.6,
                                                   V160_9 == 8 ~ 0.7,
                                                   V160_9 == 9 ~ 0.8,
                                                   V160_9 == 10 ~ 0.9,
                                                   V160_9 == 11 ~ 1,
                                                   V80_10 == 1 ~ 1,
                                                   V80_10 == 2 ~ 0.9,
                                                   V80_10 == 3 ~ 0.8,
                                                   V80_10 == 4 ~ 0.7,
                                                   V80_10 == 5 ~ 0.6,
                                                   V80_10 == 6 ~ 0.5,
                                                   V80_10 == 7 ~ 0.4,
                                                   V80_10 == 8 ~ 0.3,
                                                   V80_10 == 9 ~ 0.2,
                                                   V80_10 == 10 ~ 0.1,
                                                   V80_10 == 11 ~ 0.0))

FGNfirst <- FGNfirst %>% mutate(immigrants.R.asset.resp.agree = case_when(immigrants.R.asset == 0.6 ~ 1,
                                                              immigrants.R.asset == 0.7 ~ 1,
                                                              immigrants.R.asset == 0.8 ~ 1,
                                                              immigrants.R.asset == 0.9 ~ 1,
                                                              immigrants.R.asset == 1 ~ 1,
                                                              immigrants.R.asset == 0.0 ~ 0,
                                                              immigrants.R.asset == 0.1 ~ 0,
                                                              immigrants.R.asset == 0.2 ~ 0,
                                                              immigrants.R.asset == 0.3 ~ 0,
                                                              immigrants.R.asset == 0.4 ~ 0))
FGNfirst <- FGNfirst %>% mutate(immigrants.R.asset.resp.disagree = case_when(immigrants.R.asset == 0.6 ~ 0,
                                                                 immigrants.R.asset == 0.7 ~ 0,
                                                                 immigrants.R.asset == 0.8 ~ 0,
                                                                 immigrants.R.asset == 0.9 ~ 0,
                                                                 immigrants.R.asset == 1 ~ 0,
                                                                 immigrants.R.asset == 0.0 ~ 1,
                                                                 immigrants.R.asset == 0.1 ~ 1,
                                                                 immigrants.R.asset == 0.2 ~ 1,
                                                                 immigrants.R.asset == 0.3 ~ 1,
                                                                 immigrants.R.asset == 0.4 ~ 1))
FGNfirst <- FGNfirst %>% mutate(immigrants.R.asset.resp.dk = case_when(immigrants.R.asset == 0.5 ~ 1))
FGNfirst  <- mutate(FGNfirst, immigrants.R.asset.resp.dk = ifelse(is.na(immigrants.R.asset.resp.dk), 0, immigrants.R.asset.resp.dk))

#islam.not.restricted
FGNfirst <- FGNfirst %>% mutate(islam.not.restricted = case_when(V160_11 == 1 ~ 0.0,
                                                     V160_11 == 2 ~ 0.1,
                                                     V160_11 == 3 ~ 0.2,
                                                     V160_11 == 4 ~ 0.3,
                                                     V160_11 == 5 ~ 0.4,
                                                     V160_11 == 6 ~ 0.5,
                                                     V160_11 == 7 ~ 0.6,
                                                     V160_11 == 8 ~ 0.7,
                                                     V160_11 == 9 ~ 0.8,
                                                     V160_11 == 10 ~ 0.9,
                                                     V160_11 == 11 ~ 1,
                                                     V80_12 == 1 ~ 1,
                                                     V80_12 == 2 ~ 0.9,
                                                     V80_12 == 3 ~ 0.8,
                                                     V80_12 == 4 ~ 0.7,
                                                     V80_12 == 5 ~ 0.6,
                                                     V80_12 == 6 ~ 0.5,
                                                     V80_12 == 7 ~ 0.4,
                                                     V80_12 == 8 ~ 0.3,
                                                     V80_12 == 9 ~ 0.2,
                                                     V80_12 == 10 ~ 0.1,
                                                     V80_12 == 11 ~ 0.0))
FGNfirst <- FGNfirst %>% mutate(islam.not.restricted.resp.agree = case_when(islam.not.restricted == 0.6 ~ 1,
                                                                islam.not.restricted == 0.7 ~ 1,
                                                                islam.not.restricted == 0.8 ~ 1,
                                                                islam.not.restricted == 0.9 ~ 1,
                                                                islam.not.restricted == 1 ~ 1,
                                                                islam.not.restricted == 0.0 ~ 0,
                                                                islam.not.restricted == 0.1 ~ 0,
                                                                islam.not.restricted == 0.2 ~ 0,
                                                                islam.not.restricted == 0.3 ~ 0,
                                                                islam.not.restricted == 0.4 ~ 0))
FGNfirst <- FGNfirst %>% mutate(islam.not.restricted.resp.disagree = case_when(islam.not.restricted == 0.6 ~ 0,
                                                                   islam.not.restricted == 0.7 ~ 0,
                                                                   islam.not.restricted == 0.8 ~ 0,
                                                                   islam.not.restricted == 0.9 ~ 0,
                                                                   islam.not.restricted == 1 ~ 0,
                                                                   islam.not.restricted == 0.0 ~ 1,
                                                                   islam.not.restricted == 0.1 ~ 1,
                                                                   islam.not.restricted == 0.2 ~ 1,
                                                                   islam.not.restricted == 0.3 ~ 1,
                                                                   islam.not.restricted == 0.4 ~ 1))
FGNfirst <- FGNfirst %>% mutate(islam.not.restricted.resp.dk = case_when(islam.not.restricted == 0.5 ~ 1))
FGNfirst  <- mutate(FGNfirst, islam.not.restricted.resp.dk = ifelse(is.na(islam.not.restricted.resp.dk), 0, islam.not.restricted.resp.dk))

#equal.pay.by.law
FGNfirst <- FGNfirst %>% mutate(equal.pay.by.law = case_when(V160_13 == 1 ~ 0.0,
                                                 V160_13 == 2 ~ 0.1,
                                                 V160_13 == 3 ~ 0.2,
                                                 V160_13 == 4 ~ 0.3,
                                                 V160_13 == 5 ~ 0.4,
                                                 V160_13 == 6 ~ 0.5,
                                                 V160_13 == 7 ~ 0.6,
                                                 V160_13 == 8 ~ 0.7,
                                                 V160_13 == 9 ~ 0.8,
                                                 V160_13 == 10 ~ 0.9,
                                                 V160_13 == 11 ~ 1,
                                                 V80_14 == 1 ~ 1,
                                                 V80_14 == 2 ~ 0.9,
                                                 V80_14 == 3 ~ 0.8,
                                                 V80_14 == 4 ~ 0.7,
                                                 V80_14 == 5 ~ 0.6,
                                                 V80_14 == 6 ~ 0.5,
                                                 V80_14 == 7 ~ 0.4,
                                                 V80_14 == 8 ~ 0.3,
                                                 V80_14 == 9 ~ 0.2,
                                                 V80_14 == 10 ~ 0.1,
                                                 V80_14 == 11 ~ 0.0))

FGNfirst <- FGNfirst %>% mutate(equal.pay.by.law.resp.agree = case_when(equal.pay.by.law == 0.6 ~ 1,
                                                            equal.pay.by.law == 0.7 ~ 1,
                                                            equal.pay.by.law == 0.8 ~ 1,
                                                            equal.pay.by.law == 0.9 ~ 1,
                                                            equal.pay.by.law == 1 ~ 1,
                                                            equal.pay.by.law == 0.0 ~ 0,
                                                            equal.pay.by.law == 0.1 ~ 0,
                                                            equal.pay.by.law == 0.2 ~ 0,
                                                            equal.pay.by.law == 0.3 ~ 0,
                                                            equal.pay.by.law == 0.4 ~ 0))

FGNfirst <- FGNfirst %>% mutate(equal.pay.by.law.resp.disagree = case_when(equal.pay.by.law == 0.6 ~ 0,
                                                               equal.pay.by.law == 0.7 ~ 0,
                                                               equal.pay.by.law == 0.8 ~ 0,
                                                               equal.pay.by.law == 0.9 ~ 0,
                                                               equal.pay.by.law == 1 ~ 0,
                                                               equal.pay.by.law == 0.0 ~ 1,
                                                               equal.pay.by.law == 0.1 ~ 1,
                                                               equal.pay.by.law == 0.2 ~ 1,
                                                               equal.pay.by.law == 0.3 ~ 1,
                                                               equal.pay.by.law == 0.4 ~ 1))
FGNfirst <- FGNfirst %>% mutate(equal.pay.by.law.resp.dk = case_when(equal.pay.by.law == 0.5 ~ 1))
FGNfirst  <- mutate(FGNfirst, equal.pay.by.law.resp.dk = ifelse(is.na(equal.pay.by.law.resp.dk), 0, equal.pay.by.law.resp.dk))

#homoco.may.adopt
FGNfirst$V80_16 #Homosexual couples should be allowed to adopt children - 0 - Disagree - 10 - Agree
FGNfirst$V160_15 #Homosexual couples should not be allowed to adopt children - 0 - Disagree - 10 - Agree
#let op hier is het in de originele data andersom gecodeerd. Ik ga nog steeds hercoderen met hoger=linkser/progressiever

FGNfirst <- FGNfirst %>% mutate(homoco.may.adopt = case_when(V80_16 == 1 ~ 0.0,
                                                 V80_16 == 2 ~ 0.1,
                                                 V80_16 == 3 ~ 0.2,
                                                 V80_16 == 4 ~ 0.3,
                                                 V80_16 == 5 ~ 0.4,
                                                 V80_16 == 6 ~ 0.5,
                                                 V80_16 == 7 ~ 0.6,
                                                 V80_16 == 8 ~ 0.7,
                                                 V80_16 == 9 ~ 0.8,
                                                 V80_16 == 10 ~ 0.9,
                                                 V80_16 == 11 ~ 1,
                                                 V160_15 == 1 ~ 1,
                                                 V160_15 == 2 ~ 0.9,
                                                 V160_15 == 3 ~ 0.8,
                                                 V160_15 == 4 ~ 0.7,
                                                 V160_15 == 5 ~ 0.6,
                                                 V160_15 == 6 ~ 0.5,
                                                 V160_15 == 7 ~ 0.4,
                                                 V160_15 == 8 ~ 0.3,
                                                 V160_15 == 9 ~ 0.2,
                                                 V160_15 == 10 ~ 0.1,
                                                 V160_15 == 11 ~ 0.0))

FGNfirst <- FGNfirst %>% mutate(homoco.may.adopt.resp.agree = case_when(homoco.may.adopt == 0.6 ~ 1,
                                                            homoco.may.adopt == 0.7 ~ 1,
                                                            homoco.may.adopt == 0.8 ~ 1,
                                                            homoco.may.adopt == 0.9 ~ 1,
                                                            homoco.may.adopt == 1 ~ 1,
                                                            homoco.may.adopt == 0.0 ~ 0,
                                                            homoco.may.adopt == 0.1 ~ 0,
                                                            homoco.may.adopt == 0.2 ~ 0,
                                                            homoco.may.adopt == 0.3 ~ 0,
                                                            homoco.may.adopt == 0.4 ~ 0))
FGNfirst <- FGNfirst %>% mutate(homoco.may.adopt.resp.disagree = case_when(homoco.may.adopt == 0.6 ~ 0,
                                                               homoco.may.adopt == 0.7 ~ 0,
                                                               homoco.may.adopt == 0.8 ~ 0,
                                                               homoco.may.adopt == 0.9 ~ 0,
                                                               homoco.may.adopt == 1 ~ 0,
                                                               homoco.may.adopt == 0.0 ~ 1,
                                                               homoco.may.adopt == 0.1 ~ 1,
                                                               homoco.may.adopt == 0.2 ~ 1,
                                                               homoco.may.adopt == 0.3 ~ 1,
                                                               homoco.may.adopt == 0.4 ~ 1))
FGNfirst <- FGNfirst %>% mutate(homoco.may.adopt.resp.dk = case_when(homoco.may.adopt == 0.5 ~ 1))
FGNfirst  <- mutate(FGNfirst, homoco.may.adopt.resp.dk = ifelse(is.na(homoco.may.adopt.resp.dk), 0, homoco.may.adopt.resp.dk))

#--------------------------------------#
#--- migration background variables ---#
#--------------------------------------#

#migration background dummy
FGNfirst <- FGNfirst %>% mutate(MigBckgrnd = case_when(catrace == "Turkey" ~ 1,
                                                catrace == "Morocco" ~ 1,
                                                catrace == "Surinam" ~ 1,
                                                catrace == "FSU" ~ 1,
                                                catrace == "North-Africa" ~ 1,
                                                catrace == "Sub-Saharan Africa" ~ 1,
                                                catrace == "Other" ~ 1,
                                                catrace == "Dutch" ~ 0,
                                                catrace == "France" ~ 0,
                                                catrace == "German" ~ 0))
table(FGNfirst$MigBckgrnd, useNA = "always")

#-----------------------------#
#--- Independent variables ---#
#-----------------------------#

#recoding choice
FGNfirst <- FGNfirst %>% mutate(DVcho_1 = case_when(FGNfirst$V380 == 1 ~ 1,
                                        FGNfirst$V380 == 2 ~ 0))
FGNfirst <- FGNfirst %>% mutate(DVcho_2 = case_when(FGNfirst$V380 == 1 ~ 0,
                                        FGNfirst$V380 == 2 ~ 1))
FGNfirst <- FGNfirst %>% mutate(DVcho_3 = case_when(FGNfirst$V410 == 1 ~ 1,
                                        FGNfirst$V410 == 2 ~ 0))
FGNfirst <- FGNfirst %>% mutate(DVcho_4 = case_when(FGNfirst$V410 == 1 ~ 0,
                                        FGNfirst$V410 == 2 ~ 1))
FGNfirst <- FGNfirst %>% mutate(DVcho_5 = case_when(FGNfirst$V440 == 1 ~ 1,
                                        FGNfirst$V440 == 2 ~ 0))
FGNfirst <- FGNfirst %>% mutate(DVcho_6 = case_when(FGNfirst$V440 == 1 ~ 0,
                                        FGNfirst$V440 == 2 ~ 1))

#dummyvariables of top down ethnicity
#FGNfirst
FGNfirst <- FGNfirst %>% mutate(catTur = case_when(catrace == "Turkey" ~ "Turkish citizen",
                                         catrace == "Morocco" ~ "non-Turkish immigrant",
                                         catrace == "Surinam" ~ "non-Turkish immigrant",
                                         catrace == "FSU" ~ "non-Turkish immigrant",
                                         catrace == "North-Africa" ~ "non-Turkish immigrant",
                                         catrace == "Sub-Saharan Africa" ~ "non-Turkish immigrant",
                                         catrace == "Other" ~ "non-Turkish immigrant",
                                         catrace == "Dutch" ~ "Native citizen",
                                         catrace == "France" ~ "Native citizen",
                                         catrace == "German" ~ "Native citizen"))
FGN$catTur <- as.factor(FGN$catTur)
FGNfirst <- FGNfirst %>% mutate(catMag = case_when(catrace == "Turkey" ~ 0,
                                         catrace == "Morocco" ~ 0,
                                         catrace == "Surinam" ~ 0,
                                         catrace == "FSU" ~ 0,
                                         catrace == "North-Africa" ~ 1,
                                         catrace == "Sub-Saharan Africa" ~ 0,
                                         catrace == "Other" ~ 0,
                                         catrace == "Dutch" ~ 0,
                                         catrace == "France" ~ 0,
                                         catrace == "German" ~ 0))
FGNfirst <- FGNfirst %>% mutate(catSSA = case_when(catrace == "Turkey" ~ 0,
                                         catrace == "Morocco" ~ 0,
                                         catrace == "Surinam" ~ 0,
                                         catrace == "FSU" ~ 0,
                                         catrace == "North-Africa" ~ 0,
                                         catrace == "Sub-Saharan Africa" ~ 1,
                                         catrace == "Other" ~ 0,
                                         catrace == "Dutch" ~ 0,
                                         catrace == "France" ~ 0,
                                         catrace == "German" ~ 0))
FGNfirst <- FGNfirst %>% mutate(catNoMig = case_when(catrace == "Turkey" ~ 0,
                                           catrace == "Morocco" ~ 0,
                                           catrace == "Surinam" ~ 0,
                                           catrace == "FSU" ~ 0,
                                           catrace == "North-Africa" ~ 0,
                                           catrace == "Sub-Saharan Africa" ~ 0,
                                           catrace == "Other" ~ 0,
                                           catrace == "Dutch" ~ 1,
                                           catrace == "France" ~ 1,
                                           catrace == "German" ~ 1))
FGNfirst <- FGNfirst %>% mutate(catOth = case_when(catrace == "Turkey" ~ 0,
                                         catrace == "Morocco" ~ 0,
                                         catrace == "Surinam" ~ 0,
                                         catrace == "FSU" ~ 0,
                                         catrace == "North-Africa" ~ 0,
                                         catrace == "Sub-Saharan Africa" ~ 0,
                                         catrace == "Other" ~ 1,
                                         catrace == "Dutch" ~ 0,
                                         catrace == "France" ~ 0,
                                         catrace == "German" ~ 0))
FGNfirst <- FGNfirst %>% mutate(catFSU = case_when(catrace == "Turkey" ~ 0,
                                         catrace == "Morocco" ~ 0,
                                         catrace == "Surinam" ~ 0,
                                         catrace == "FSU" ~ 1,
                                         catrace == "North-Africa" ~ 0,
                                         catrace == "Sub-Saharan Africa" ~ 0,
                                         catrace == "Other" ~ 0,
                                         catrace == "Dutch" ~ 0,
                                         catrace == "France" ~ 0,
                                         catrace == "German" ~ 0))
FGNfirst <- FGNfirst %>% mutate(catMor = case_when(catrace == "Turkey" ~ 0,
                                         catrace == "Morocco" ~ 1,
                                         catrace == "Surinam" ~ 0,
                                         catrace == "FSU" ~ 0,
                                         catrace == "North-Africa" ~ 0,
                                         catrace == "Sub-Saharan Africa" ~ 0,
                                         catrace == "Other" ~ 0,
                                         catrace == "Dutch" ~ 0,
                                         catrace == "France" ~ 0,
                                         catrace == "German" ~ 0))
FGNfirst <- FGNfirst %>% mutate(catSur = case_when(catrace == "Turkey" ~ 0,
                                         catrace == "Morocco" ~ 0,
                                         catrace == "Surinam" ~ 1,
                                         catrace == "FSU" ~ 0,
                                         catrace == "North-Africa" ~ 0,
                                         catrace == "Sub-Saharan Africa" ~ 0,
                                         catrace == "Other" ~ 0,
                                         catrace == "Dutch" ~ 0,
                                         catrace == "France" ~ 0,
                                         catrace == "German" ~ 0))

#--------------------------------#
#--- self-identified religion ---#
#--------------------------------#

#FGNfirst
FGNfirst <- FGNfirst %>% mutate(binidrel2 = case_when(V580 == 2 ~ "Non-religious",
                                          V590 == 3 ~ "Other",
                                          V590 == 4 ~ "Other",
                                          V590 == 5 ~ "Other",
                                          V590 == 6 ~ "Other",
                                          V600 == 1 ~ "Muslim",
                                          V600 == 2 ~ "Muslim",
                                          V600 == 3 ~ "Muslim",
                                          V600 == 4 ~ "Muslim",
                                          V610 == 1 ~ "Christian",
                                          V610 == 2 ~ "Christian",
                                          V610 == 3 ~ "Christian"))
FGNfirst <- FGNfirst %>% mutate(relMus = case_when(V580 == 2 ~ "non-Muslim citizen",
                                                   V590 == 3 ~ "non-Muslim citizen",
                                                   V590 == 4 ~ "non-Muslim citizen",
                                                   V590 == 5 ~ "non-Muslim citizen",
                                                   V590 == 6 ~ "non-Muslim citizen",
                                                   V600 == 1 ~ "Muslim citizen",
                                                   V600 == 2 ~ "Muslim citizen",
                                                   V600 == 3 ~ "Muslim citizen",
                                                   V600 == 4 ~ "Muslim citizen",
                                                   V610 == 1 ~ "non-Muslim citizen",
                                                   V610 == 2 ~ "non-Muslim citizen",
                                                   V610 == 3 ~ "non-Muslim citizen"))
FGN$relMus <- as.factor(FGN$relMus)

FGNfirst <- FGNfirst %>% mutate(relChr = case_when(V580 == 2 ~ 0,
                                       V590 == 3 ~ 0,
                                       V590 == 4 ~ 0,
                                       V590 == 5 ~ 0,
                                       V590 == 6 ~ 0,
                                       V600 == 1 ~ 0,
                                       V600 == 2 ~ 0,
                                       V600 == 3 ~ 0,
                                       V600 == 4 ~ 0,
                                       V610 == 1 ~ 1,
                                       V610 == 2 ~ 1,
                                       V610 == 3 ~ 1))
FGNfirst <- FGNfirst %>% mutate(relOth = case_when(V580 == 2 ~ 0,
                                       V590 == 3 ~ 1,
                                       V590 == 4 ~ 1,
                                       V590 == 5 ~ 1,
                                       V590 == 6 ~ 1,
                                       V600 == 1 ~ 0,
                                       V600 == 2 ~ 0,
                                       V600 == 3 ~ 0,
                                       V600 == 4 ~ 0,
                                       V610 == 1 ~ 0,
                                       V610 == 2 ~ 0,
                                       V610 == 3 ~ 0))
FGNfirst <- FGNfirst %>% mutate(relNon = case_when(V580 == 2 ~ 1,
                                       V590 == 3 ~ 0,
                                       V590 == 4 ~ 0,
                                       V590 == 5 ~ 0,
                                       V590 == 6 ~ 0,
                                       V600 == 1 ~ 0,
                                       V600 == 2 ~ 0,
                                       V600 == 3 ~ 0,
                                       V600 == 4 ~ 0,
                                       V610 == 1 ~ 0,
                                       V610 == 2 ~ 0,
                                       V610 == 3 ~ 0))

#--------------------#
#--- Pivot longer ---#
#--------------------#

FGNwide <- as_tibble(FGNfirst$INTNR)  
names(FGNwide) <- "INTNR"
FGNwide$cntry <- FGNfirst$cntry

FGNwide$tax.rich.higher <- FGNfirst$tax.rich.higher
FGNwide$raise.supp.unemp <- FGNfirst$raise.supp.unemp
FGNwide$more.com.climcha <- FGNfirst$more.com.climcha
FGNwide$raise.fuel.price <- FGNfirst$raise.fuel.price
FGNwide$immigrants.R.asset <- FGNfirst$immigrants.R.asset
FGNwide$islam.not.restricted <- FGNfirst$islam.not.restricted
FGNwide$equal.pay.by.law <- FGNfirst$equal.pay.by.law
FGNwide$homoco.may.adopt <- FGNfirst$homoco.may.adopt

FGNwide$tax.rich.higher.resp.agree<- FGNfirst$tax.rich.higher.resp.agree
FGNwide$raise.supp.unemp.resp.agree <- FGNfirst$raise.supp.unemp.resp.agree
FGNwide$more.com.climcha.resp.agree <- FGNfirst$more.com.climcha.resp.agree
FGNwide$raise.fuel.price.resp.agree <- FGNfirst$raise.fuel.price.resp.agree
FGNwide$immigrants.R.asset.resp.agree <- FGNfirst$immigrants.R.asset.resp.agree
FGNwide$islam.not.restricted.resp.agree <- FGNfirst$islam.not.restricted.resp.agree
FGNwide$equal.pay.by.law.resp.agree <- FGNfirst$equal.pay.by.law.resp.agree
FGNwide$homoco.may.adopt.resp.agree <- FGNfirst$homoco.may.adopt.resp.agree

FGNwide$tax.rich.higher.resp.disagree <- FGNfirst$tax.rich.higher.resp.disagree
FGNwide$raise.supp.unemp.resp.disagree <- FGNfirst$raise.supp.unemp.resp.disagree
FGNwide$more.com.climcha.resp.disagree <- FGNfirst$more.com.climcha.resp.disagree
FGNwide$raise.fuel.price.resp.disagree <- FGNfirst$raise.fuel.price.resp.disagree
FGNwide$immigrants.R.asset.resp.disagree <- FGNfirst$immigrants.R.asset.resp.disagree
FGNwide$islam.not.restricted.resp.disagree <- FGNfirst$islam.not.restricted.resp.disagree
FGNwide$equal.pay.by.law.resp.disagree <- FGNfirst$equal.pay.by.law.resp.disagree
FGNwide$homoco.may.adopt.resp.disagree <- FGNfirst$homoco.may.adopt.resp.disagree

FGNwide$tax.rich.higher.resp.dk <- FGNfirst$tax.rich.higher.resp.dk
FGNwide$raise.supp.unemp.resp.dk <- FGNfirst$raise.supp.unemp.resp.dk
FGNwide$more.com.climcha.resp.dk <- FGNfirst$more.com.climcha.resp.dk
FGNwide$raise.fuel.price.resp.dk <- FGNfirst$raise.fuel.price.resp.dk
FGNwide$immigrants.R.asset.resp.dk <- FGNfirst$immigrants.R.asset.resp.dk
FGNwide$islam.not.restricted.resp.dk <- FGNfirst$islam.not.restricted.resp.dk
FGNwide$equal.pay.by.law.resp.dk <- FGNfirst$equal.pay.by.law.resp.dk
FGNwide$homoco.may.adopt.resp.dk <- FGNfirst$homoco.may.adopt.resp.dk

FGNwide$w8eth <- FGNfirst$w8eth
FGNwide$Age <- FGNfirst$Age
FGNwide$AGE2 <- FGNfirst$AGE2
FGNwide$Education <- FGNfirst$Education
FGNwide$Woman <- FGNfirst$Woman
FGNwide$catrace <- FGNfirst$catrace

FGNwide$MigBckgrnd <- FGNfirst$MigBckgrnd
FGNwide$catTur <- FGNfirst$catTur
FGNwide$catMag <- FGNfirst$catMag
FGNwide$catSSA <- FGNfirst$catSSA
FGNwide$catNoMig <- FGNfirst$catNoMig
FGNwide$catOth <- FGNfirst$catOth
FGNwide$catFSU <- FGNfirst$catFSU
FGNwide$catMor <- FGNfirst$catMor
FGNwide$catSur <- FGNfirst$catSur

FGNwide$binidrel2 <- FGNfirst$binidrel2
FGNwide$relMus <- FGNfirst$relMus
FGNwide$relChr <- FGNfirst$relChr
FGNwide$relOth <- FGNfirst$relOth
FGNwide$relNon <- FGNfirst$relNon

FGNwide$idprofnogen_1 <- FGNfirst$idprofnogen_1
FGNwide$idprofnogen_2 <- FGNfirst$idprofnogen_2
FGNwide$idprofnogen_3 <- FGNfirst$idprofnogen_3
FGNwide$idprofnogen_4 <- FGNfirst$idprofnogen_4
FGNwide$idprofnogen_5 <- FGNfirst$idprofnogen_5
FGNwide$idprofnogen_6 <- FGNfirst$idprofnogen_6

FGNwide$idprofgen_1 <- FGNfirst$idprofgen_1
FGNwide$idprofgen_2 <- FGNfirst$idprofgen_2
FGNwide$idprofgen_3 <- FGNfirst$idprofgen_3
FGNwide$idprofgen_4 <- FGNfirst$idprofgen_4
FGNwide$idprofgen_5 <- FGNfirst$idprofgen_5
FGNwide$idprofgen_6 <- FGNfirst$idprofgen_6

FGNwide$idprofpp_1 <- FGNfirst$idprofpp_1
FGNwide$idprofpp_2 <- FGNfirst$idprofpp_2
FGNwide$idprofpp_3 <- FGNfirst$idprofpp_3
FGNwide$idprofpp_4 <- FGNfirst$idprofpp_4
FGNwide$idprofpp_5 <- FGNfirst$idprofpp_5
FGNwide$idprofpp_6 <- FGNfirst$idprofpp_6

FGNwide$DVcho_1 <- FGNfirst$DVcho_1
FGNwide$DVcho_2 <- FGNfirst$DVcho_2
FGNwide$DVcho_3 <- FGNfirst$DVcho_3
FGNwide$DVcho_4 <- FGNfirst$DVcho_4
FGNwide$DVcho_5 <- FGNfirst$DVcho_5
FGNwide$DVcho_6 <- FGNfirst$DVcho_6

FGNwide$DVrep_1 <- FGNfirst$DVrep_1
FGNwide$DVrep_2 <- FGNfirst$DVrep_2
FGNwide$DVrep_3 <- FGNfirst$DVrep_3
FGNwide$DVrep_4 <- FGNfirst$DVrep_4
FGNwide$DVrep_5 <- FGNfirst$DVrep_5
FGNwide$DVrep_6 <- FGNfirst$DVrep_6

FGNwide$DVtru_1 <- FGNfirst$DVtru_1
FGNwide$DVtru_2 <- FGNfirst$DVtru_2
FGNwide$DVtru_3 <- FGNfirst$DVtru_3
FGNwide$DVtru_4 <- FGNfirst$DVtru_4
FGNwide$DVtru_5 <- FGNfirst$DVtru_5
FGNwide$DVtru_6 <- FGNfirst$DVtru_6

FGNwide$DVcom_1 <- FGNfirst$DVcom_1
FGNwide$DVcom_2 <- FGNfirst$DVcom_2
FGNwide$DVcom_3 <- FGNfirst$DVcom_3
FGNwide$DVcom_4 <- FGNfirst$DVcom_4
FGNwide$DVcom_5 <- FGNfirst$DVcom_5
FGNwide$DVcom_6 <- FGNfirst$DVcom_6

#pivot
FGN <- FGNwide %>%
  pivot_longer(
    c(-INTNR,
      -cntry,
      
      -tax.rich.higher,
      -raise.supp.unemp,
      -more.com.climcha,
      -raise.fuel.price,
      -immigrants.R.asset,
      -islam.not.restricted,
      -equal.pay.by.law,
      -homoco.may.adopt,
      
      -tax.rich.higher.resp.agree,
      -raise.supp.unemp.resp.agree,
      -more.com.climcha.resp.agree,
      -raise.fuel.price.resp.agree,
      -immigrants.R.asset.resp.agree,
      -islam.not.restricted.resp.agree,
      -equal.pay.by.law.resp.agree,
      -homoco.may.adopt.resp.agree,
      
      -tax.rich.higher.resp.disagree,
      -raise.supp.unemp.resp.disagree,
      -more.com.climcha.resp.disagree,
      -raise.fuel.price.resp.disagree,
      -immigrants.R.asset.resp.disagree,
      -islam.not.restricted.resp.disagree,
      -equal.pay.by.law.resp.disagree,
      -homoco.may.adopt.resp.disagree,
      
      -tax.rich.higher.resp.dk,
      -raise.supp.unemp.resp.dk,
      -more.com.climcha.resp.dk,
      -raise.fuel.price.resp.dk,
      -immigrants.R.asset.resp.dk,
      -islam.not.restricted.resp.dk,
      -equal.pay.by.law.resp.dk,
      -homoco.may.adopt.resp.dk,
      
      -w8eth,
      -Age ,
      -AGE2,
      -Education ,
      -Woman ,
      -catrace ,
      
      -MigBckgrnd ,
      -catTur ,
      -catMag ,
      -catSSA ,
      -catNoMig,
      -catOth ,
      -catFSU ,
      -catMor ,
      -catSur ,
      
      -binidrel2 ,
      -relMus ,
      -relChr ,
      -relOth ,
      -relNon),
    names_to = c(".value", "profile"),
    names_sep = "_",
    values_drop_na = F)

#-----------------------------------#
#--- recode profiles politicians ---#
#-----------------------------------#

#religion
FGN <- FGN %>% mutate(Politician.Religion = case_when(idprofnogen == 1 ~ "Muslim politician",
                                                      idprofnogen == 4 ~ "Muslim politician",
                                                      idprofnogen == 7 ~ "Muslim politician",
                                                      idprofnogen == 10 ~ "Muslim politician",
                                                      
                                                      idprofnogen == 2 ~ "Christian politician",
                                                      idprofnogen == 5 ~ "Christian politician",
                                                      idprofnogen == 8 ~ "Christian politician",
                                                      idprofnogen == 11 ~ "Christian politician",
                                                      
                                                      idprofnogen == 3 ~ "non-religious politician",
                                                      idprofnogen == 6 ~ "non-religious politician",
                                                      idprofnogen == 9 ~ "non-religious politician",
                                                      idprofnogen == 12 ~ "non-religious politician")) 
FGN$Politician.Religion <- as.factor(FGN$Politician.Religion)
FGN <- FGN %>% mutate(Politician.is.Muslim = case_when(idprofnogen == 1 ~  1,
                                                       idprofnogen == 4 ~  1,
                                                       idprofnogen == 7 ~  1,
                                                       idprofnogen == 10 ~ 1,
                                                       
                                                       idprofnogen == 2 ~  0,
                                                       idprofnogen == 5 ~  0,
                                                       idprofnogen == 8 ~  0,
                                                       idprofnogen == 11 ~ 0,
                                                       
                                                       idprofnogen == 3 ~  0,
                                                       idprofnogen == 6 ~  0,
                                                       idprofnogen == 9 ~  0,
                                                       idprofnogen == 12 ~ 0))
FGN$Politician.is.Muslim <- as.factor(FGN$Politician.is.Muslim)
FGN <- FGN %>% mutate(Politician.is.Christ = case_when(idprofnogen == 1 ~  0,
                                                       idprofnogen == 4 ~  0,
                                                       idprofnogen == 7 ~  0,
                                                       idprofnogen == 10 ~ 0,
                                                       
                                                       idprofnogen == 2 ~  1,
                                                       idprofnogen == 5 ~  1,
                                                       idprofnogen == 8 ~  1,
                                                       idprofnogen == 11 ~ 1,
                                                       
                                                       idprofnogen == 3 ~  0,
                                                       idprofnogen == 6 ~  0,
                                                       idprofnogen == 9 ~  0,
                                                       idprofnogen == 12 ~ 0))
FGN$Politician.is.Christ <- as.factor(FGN$Politician.is.Christ)
FGN <- FGN %>% mutate(Politician.is.NonRel = case_when(idprofnogen == 1 ~  0,
                                                       idprofnogen == 4 ~  0,
                                                       idprofnogen == 7 ~  0,
                                                       idprofnogen == 10 ~ 0,
                                                       
                                                       idprofnogen == 2 ~  0,
                                                       idprofnogen == 5 ~  0,
                                                       idprofnogen == 8 ~  0,
                                                       idprofnogen == 11 ~ 0,
                                                       
                                                       idprofnogen == 3 ~  1,
                                                       idprofnogen == 6 ~  1,
                                                       idprofnogen == 9 ~  1,
                                                       idprofnogen == 12 ~ 1))
FGN$Politician.is.NonRel <- as.factor(FGN$Politician.is.NonRel)

FGN <- FGN %>% mutate(Citizen.Religion = case_when(binidrel2 == "Muslim" ~ "Muslim citizen",
                                                      binidrel2 == "Christian" ~ "Christian citizen",
                                                      #binidrel2 == "Other" ~ "Other citizen",
                                                      binidrel2 == "Non-religious" ~ "non-religious citizen")) 
FGN$Citizen.Religion <- as.factor(FGN$Citizen.Religion)

#Gender
FGN <- FGN %>% mutate(Politician.Gender = case_when(between(idprofgen, 1, 9) ~ "Female politician",
                                                    between(idprofgen, 10, 18) ~ "Male politician",
                                                    between(idprofgen, 19, 26) ~ "Female politician",
                                                    between(idprofgen, 27, 34) ~ "Male politician",
                                                    between(idprofgen, 35, 44) ~ "Female politician",
                                                    between(idprofgen, 45, 54) ~ "Male politician",
                                                    between(idprofgen, 55, 63) ~ "Female politician",
                                                    between(idprofgen, 64, 75) ~ "Male politician",
                                                    between(idprofgen, 76, 80) ~ "Female politician")) 
FGN$Politician.Gender <- as.factor(FGN$Politician.Gender)
FGN <- FGN %>% mutate(Politician.is.Woman = case_when(Politician.Gender == "Male politician" ~  0,
                                                       Politician.Gender == "Female politician" ~  1))
FGN$Politician.is.Woman <- as.factor(FGN$Politician.is.Woman)

FGN <- FGN %>% mutate(Politician.is.Man = case_when(Politician.Gender == "Male politician" ~  1,
                                                      Politician.Gender == "Female politician" ~  0))
FGN$Politician.is.Woman <- as.factor(FGN$Politician.is.Man)

FGN <- FGN %>% mutate(Citizen.Gender = case_when(Woman == 1 ~ "Woman",
                                                 Woman == 0 ~ "Man")) 
FGN$Citizen.Gender <- as.factor(FGN$Citizen.Gender)

#Ethnorace
FGN <- FGN %>% mutate(Politician.Ethnorace = case_when(idprofnogen == 1 ~ "Turkish politician",
                                                       idprofnogen == 2 ~ "Turkish politician",
                                                       idprofnogen == 3 ~ "Turkish politician",
                                                       
                                                       #France
                                                       #Maghrebi
                                                       idprofnogen == 4 & cntry == "France" ~ "Maghrebi politician",
                                                       idprofnogen == 5 & cntry == "France" ~ "Maghrebi politician",
                                                       idprofnogen == 6 & cntry == "France" ~ "Maghrebi politician",
                                                       
                                                       idprofnogen == 4 & cntry == "France" ~ "Maghrebi politician",
                                                       idprofnogen == 5 & cntry == "France" ~ "Maghrebi politician",
                                                       idprofnogen == 6 & cntry == "France" ~ "Maghrebi politician",
                                                       
                                                       idprofnogen == 4 & cntry == "France" ~ "Maghrebi politician",
                                                       idprofnogen == 5 & cntry == "France" ~ "Maghrebi politician",
                                                       idprofnogen == 6 & cntry == "France" ~ "Maghrebi politician",
                                                       
                                                       #Sub-Saharan African
                                                       idprofnogen == 7 & cntry == "France" ~ "Sub-Saharan African politician",
                                                       idprofnogen == 8 & cntry == "France" ~ "Sub-Saharan African politician",
                                                       idprofnogen == 9 & cntry == "France" ~ "Sub-Saharan African politician",
                                                       
                                                       idprofnogen == 7 & cntry == "France" ~ "Sub-Saharan African politician",
                                                       idprofnogen == 8 & cntry == "France" ~ "Sub-Saharan African politician",
                                                       idprofnogen == 9 & cntry == "France" ~ "Sub-Saharan African politician",
                                                       
                                                       idprofnogen == 7 & cntry == "France" ~ "Sub-Saharan African politician",
                                                       idprofnogen == 8 & cntry == "France" ~ "Sub-Saharan African politician",
                                                       idprofnogen == 9 & cntry == "France" ~ "Sub-Saharan African politician",
                                                       
                                                       #Germany
                                                       #Maghrebi
                                                       idprofnogen == 4 & cntry == "Germany" ~ "FSU politician",
                                                       idprofnogen == 5 & cntry == "Germany" ~ "FSU politician",
                                                       idprofnogen == 6 & cntry == "Germany" ~ "FSU politician",
                                                       
                                                       idprofnogen == 4 & cntry == "Germany" ~ "FSU politician",
                                                       idprofnogen == 5 & cntry == "Germany" ~ "FSU politician",
                                                       idprofnogen == 6 & cntry == "Germany" ~ "FSU politician",
                                                       
                                                       idprofnogen == 4 & cntry == "Germany" ~ "FSU politician",
                                                       idprofnogen == 5 & cntry == "Germany" ~ "FSU politician",
                                                       idprofnogen == 6 & cntry == "Germany" ~ "FSU politician",
                                                       
                                                       #Netherlands
                                                       #Moroccan
                                                       idprofnogen == 4 & cntry == "Netherlands" ~ "Moroccan politician",
                                                       idprofnogen == 5 & cntry == "Netherlands" ~ "Moroccan politician",
                                                       idprofnogen == 6 & cntry == "Netherlands" ~ "Moroccan politician",
                                                       
                                                       idprofnogen == 4 & cntry == "Netherlands" ~ "Moroccan politician",
                                                       idprofnogen == 5 & cntry == "Netherlands" ~ "Moroccan politician",
                                                       idprofnogen == 6 & cntry == "Netherlands" ~ "Moroccan politician",
                                                       
                                                       idprofnogen == 4 & cntry == "Netherlands" ~ "Moroccan politician",
                                                       idprofnogen == 5 & cntry == "Netherlands" ~ "Moroccan politician",
                                                       idprofnogen == 6 & cntry == "Netherlands" ~ "Moroccan politician",
                                                       
                                                       #Sub-Saharan African
                                                       idprofnogen == 7 & cntry == "Netherlands" ~ "Surinamese politician",
                                                       idprofnogen == 8 & cntry == "Netherlands" ~ "Surinamese politician",
                                                       idprofnogen == 9 & cntry == "Netherlands" ~ "Surinamese politician",
                                                       
                                                       idprofnogen == 7 & cntry == "Netherlands" ~ "Surinamese politician",
                                                       idprofnogen == 8 & cntry == "Netherlands" ~ "Surinamese politician",
                                                       idprofnogen == 9 & cntry == "Netherlands" ~ "Surinamese politician",
                                                       
                                                       idprofnogen == 7 & cntry == "Netherlands" ~ "Surinamese politician",
                                                       idprofnogen == 8 & cntry == "Netherlands" ~ "Surinamese politician",
                                                       idprofnogen == 9 & cntry == "Netherlands" ~ "Surinamese politician",
                                                       
                                                       #no mig bckgrnd
                                                       idprofnogen == 10 ~ "Politician without migration background",
                                                       idprofnogen == 11 ~ "Politician without migration background",
                                                       idprofnogen == 12 ~ "Politician without migration background")) 
FGN$Politician.Ethnorace <- as.factor(FGN$Politician.Ethnorace)

##
FGN <- FGN %>% mutate(Politician.frm.Tur = case_when(idprofnogen == 1 ~ 1,
                                                        idprofnogen == 2 ~ 1,
                                                        idprofnogen == 3 ~ 1,
                                                        
                                                        idprofnogen == 4 ~ 0,
                                                        idprofnogen == 5 ~ 0,
                                                        idprofnogen == 6 ~ 0,
                                                        
                                                        idprofnogen == 7 ~ 0,
                                                        idprofnogen == 8 ~ 0,
                                                        idprofnogen == 9 ~ 0,
                                                        
                                                        idprofnogen == 10 ~ 0,
                                                        idprofnogen == 11 ~ 0,
                                                        idprofnogen == 12 ~ 0)) 
FGN$Politician.frm.Tur <- as.factor(FGN$Politician.frm.Tur)

#NoMig
FGN <- FGN %>% mutate(Politician.frm.FGN = case_when(Politician.Ethnorace == "Politician without migration background" ~ 1))
FGN$Politician.frm.FGN <- as.factor(FGN$Politician.frm.FGN)
FGN  <- mutate(FGN, Politician.frm.FGN = ifelse(is.na(Politician.frm.FGN), 0, Politician.frm.FGN))

#Mag
FGN <- FGN %>% mutate(Politician.frm.Mag = case_when(Politician.Ethnorace == "Maghrebi politician" ~ 1))
FGN$Politician.frm.Mag <- as.factor(FGN$Politician.frm.Mag)
FGN  <- mutate(FGN, Politician.frm.Mag = ifelse(is.na(Politician.frm.Mag), 0, Politician.frm.Mag))

#SSA
FGN <- FGN %>% mutate(Politician.frm.SSA = case_when(Politician.Ethnorace == "Sub-Saharan African politician" ~ 1))
FGN$Politician.frm.SSA <- as.factor(FGN$Politician.frm.SSA)
FGN  <- mutate(FGN, Politician.frm.SSA = ifelse(is.na(Politician.frm.SSA), 0, Politician.frm.SSA))

#FSU
FGN <- FGN %>% mutate(Politician.frm.FSU = case_when(Politician.Ethnorace == "FSU politician" ~ 1))
FGN$Politician.frm.FSU <- as.factor(FGN$Politician.frm.FSU)
FGN  <- mutate(FGN, Politician.frm.FSU = ifelse(is.na(Politician.frm.FSU), 0, Politician.frm.FSU))

#Mor
FGN <- FGN %>% mutate(Politician.frm.Mor = case_when(Politician.Ethnorace == "Moroccan politician" ~ 1))
FGN$Politician.frm.Mor <- as.factor(FGN$Politician.frm.Mor)
FGN  <- mutate(FGN, Politician.frm.Mor = ifelse(is.na(Politician.frm.Mor), 0, Politician.frm.Mor))

#Sur
FGN <- FGN %>% mutate(Politician.frm.Sur = case_when(Politician.Ethnorace == "Surinamese politician" ~ 1))
FGN$Politician.frm.Sur <- as.factor(FGN$Politician.frm.Sur)
FGN  <- mutate(FGN, Politician.frm.Sur = ifelse(is.na(Politician.frm.Sur), 0, Politician.frm.Sur))

FGN <- FGN %>% mutate(Citizen.Ethnorace = case_when(catrace == "Turkey" ~ "Turkish citizen",
                                                    
                                                    catrace == "North-Africa" ~ "North-African citizen (France)",
                                                    catrace == "Sub-Saharan Africa" ~ "Sub-Saharan African citizen (France)",
                                                    catrace == "FSU" ~ "FSU citizen (Germany)",
                                                    
                                                    catrace == "Morocco" ~ "Moroccan citizen (Netherlands)",
                                                    catrace == "Surinam" ~ "Surinamese citizen (Netherlands)",
                                                    #catrace == "Other" ~ "Other citizen",
                                                    
                                                    catrace == "Dutch" ~ "Citizen without migration background",
                                                    catrace == "France" ~ "Citizen without migration background",
                                                    catrace == "German" ~ "Citizen without migration background")) 
FGN$Citizen.Ethnorace <- as.factor(FGN$Citizen.Ethnorace)

FGN <- FGN %>% mutate(Politician.MigBckgrnd = case_when(idprofnogen == 1 ~ "Politician with migration background",
                                                        idprofnogen == 2 ~ "Politician with migration background",
                                                        idprofnogen == 3 ~ "Politician with migration background",
                                                        
                                                        #France
                                                        #Maghrebi
                                                        idprofnogen == 4 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 5 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 6 & cntry == "France" ~ "Politician with migration background",
                                                        
                                                        idprofnogen == 4 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 5 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 6 & cntry == "France" ~ "Politician with migration background",
                                                        
                                                        idprofnogen == 4 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 5 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 6 & cntry == "France" ~ "Politician with migration background",
                                                        
                                                        #Sub-Saharan African
                                                        idprofnogen == 7 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 8 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 9 & cntry == "France" ~ "Politician with migration background",
                                                        
                                                        idprofnogen == 7 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 8 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 9 & cntry == "France" ~ "Politician with migration background",
                                                        
                                                        idprofnogen == 7 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 8 & cntry == "France" ~ "Politician with migration background",
                                                        idprofnogen == 9 & cntry == "France" ~ "Politician with migration background",
                                                        
                                                        #Germany
                                                        #Maghrebi
                                                        idprofnogen == 4 & cntry == "Germany" ~ "Politician with migration background",
                                                        idprofnogen == 5 & cntry == "Germany" ~ "Politician with migration background",
                                                        idprofnogen == 6 & cntry == "Germany" ~ "Politician with migration background",
                                                        
                                                        idprofnogen == 4 & cntry == "Germany" ~ "Politician with migration background",
                                                        idprofnogen == 5 & cntry == "Germany" ~ "Politician with migration background",
                                                        idprofnogen == 6 & cntry == "Germany" ~ "Politician with migration background",
                                                        
                                                        idprofnogen == 4 & cntry == "Germany" ~ "Politician with migration background",
                                                        idprofnogen == 5 & cntry == "Germany" ~ "Politician with migration background",
                                                        idprofnogen == 6 & cntry == "Germany" ~ "Politician with migration background",
                                                        
                                                        #Netherlands
                                                        #Moroccan
                                                        idprofnogen == 4 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 5 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 6 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        
                                                        idprofnogen == 4 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 5 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 6 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        
                                                        idprofnogen == 4 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 5 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 6 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        
                                                        #Sub-Saharan African
                                                        idprofnogen == 7 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 8 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 9 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        
                                                        idprofnogen == 7 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 8 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 9 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        
                                                        idprofnogen == 7 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 8 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        idprofnogen == 9 & cntry == "Netherlands" ~ "Politician with migration background",
                                                        
                                                        #no mig bckgrnd
                                                        idprofnogen == 10 ~ "Politician without migration background",
                                                        idprofnogen == 11 ~ "Politician without migration background",
                                                        idprofnogen == 12 ~ "Politician without migration background")) 
FGN$Politician.MigBckgrnd <- as.factor(FGN$Politician.MigBckgrnd)

#Policy position
FGN <- FGN %>% mutate(Politician.Policy.Position = case_when(idprofpp == 1 ~ "The tax rate for the rich must be higher",
                                                             idprofpp == 2 ~ "The tax rate for the rich must be lower",
                                                             idprofpp == 3 ~ "The government should raise the support for the unemployed",
                                                             idprofpp == 4 ~ "Our government should lower the support for the unemployed",
                                                             idprofpp == 5 ~ "Our government should do more to combat climate change than now",
                                                             idprofpp == 6 ~ "Our government should do less to combat climate change than now",
                                                             idprofpp == 7 ~ "The government needs to raise fuel prices",
                                                             idprofpp == 8 ~ "Our government needs to lower fuel prices",
                                                             idprofpp == 9 ~ "Immigrants are an asset to our country",
                                                             idprofpp ==10 ~ "Immigrants are a burden to our country",
                                                             idprofpp ==11 ~ "Islam should not be restricted by law",
                                                             idprofpp ==12 ~ "Islam should be restricted by law",
                                                             idprofpp ==13 ~ "That men and women receive equal pay for equal work should be regulated by law",
                                                             idprofpp ==14 ~ "That men and women receive equal pay for equal work should not be regulated by law",
                                                             idprofpp ==15 ~ "Homosexual couples should not be allowed to adopt children",
                                                             idprofpp ==16 ~ "Homosexual couples should be allowed to adopt children")) 

#tax.rich.higher
FGN <- FGN %>% mutate(Politician.Policy.Position.tax.rich.higher = case_when(idprofpp == 1 ~ "tax.rich.higher politician agrees",
                                                                             idprofpp == 2 ~ "tax.rich.higher politician disagrees")) 
FGN$Politician.Policy.Position.tax.rich.higher <- as.factor(FGN$Politician.Policy.Position.tax.rich.higher)

FGN <- FGN %>% mutate(Citizen.Policy.Position.tax.rich.higher = case_when(tax.rich.higher.resp.agree == 1 ~ "tax.rich.higher citizen agrees",
                                                                          tax.rich.higher.resp.disagree == 1 ~ "tax.rich.higher citizen disagrees")) 
FGN$Citizen.Policy.Position.tax.rich.higher <- as.factor(FGN$Citizen.Policy.Position.tax.rich.higher)

FGN <- FGN %>% mutate(samepp.tax.rich.higher = case_when(idprofpp == 1 & tax.rich.higher.resp.agree == 1 ~ "Both favor",
                                                         idprofpp == 2 & tax.rich.higher.resp.disagree == 1 ~ "Both oppose",
                                                         idprofpp == 1 & tax.rich.higher.resp.disagree == 1 ~ "Politician favors/Citizen opposes",
                                                         idprofpp == 2 & tax.rich.higher.resp.agree == 1 ~ "Politician opposes/Citizen favors")) 
FGN$samepp.tax.rich.higher <- as.factor(FGN$samepp.tax.rich.higher)

#raise.supp.unemp
FGN <- FGN %>% mutate(Politician.Policy.Position.raise.supp.unemp = case_when(idprofpp == 3 ~ "raise.supp.unemp politician agrees",
                                                                             idprofpp == 4 ~ "raise.supp.unemp politician disagrees")) 
FGN$Politician.Policy.Position.raise.supp.unemp <- as.factor(FGN$Politician.Policy.Position.raise.supp.unemp)

FGN <- FGN %>% mutate(Citizen.Policy.Position.raise.supp.unemp = case_when(raise.supp.unemp.resp.agree == 1 ~ "raise.supp.unemp citizen agrees",
                                                                          raise.supp.unemp.resp.disagree == 1 ~ "raise.supp.unemp citizen disagrees")) 
FGN$Citizen.Policy.Position.raise.supp.unemp <- as.factor(FGN$Citizen.Policy.Position.raise.supp.unemp)

FGN <- FGN %>% mutate(samepp.raise.supp.unemp = case_when(idprofpp == 3 & raise.supp.unemp.resp.agree == 1 ~ "Both favor",
                                                          idprofpp == 4 & raise.supp.unemp.resp.disagree == 1 ~ "Both oppose",
                                                          idprofpp == 3 & raise.supp.unemp.resp.disagree == 1 ~ "Politician favors/Citizen opposes",
                                                          idprofpp == 4 & raise.supp.unemp.resp.agree == 1 ~ "Politician opposes/Citizen favors")) 
FGN$samepp.raise.supp.unemp <- as.factor(FGN$samepp.raise.supp.unemp)

#more.com.climcha
FGN <- FGN %>% mutate(Politician.Policy.Position.more.com.climcha = case_when(idprofpp == 5 ~ "more.com.climcha politician agrees",
                                                                             idprofpp == 6 ~ "more.com.climcha politician disagrees")) 
FGN$Politician.Policy.Position.more.com.climcha <- as.factor(FGN$Politician.Policy.Position.more.com.climcha)

FGN <- FGN %>% mutate(Citizen.Policy.Position.more.com.climcha = case_when(more.com.climcha.resp.agree == 1 ~ "more.com.climcha citizen agrees",
                                                                          more.com.climcha.resp.disagree == 1 ~ "more.com.climcha citizen disagrees")) 
FGN$Citizen.Policy.Position.more.com.climcha <- as.factor(FGN$Citizen.Policy.Position.more.com.climcha)

FGN <- FGN %>% mutate(samepp.more.com.climcha = case_when(idprofpp == 5 & more.com.climcha.resp.agree == 1 ~ "Both favor",
                                                          idprofpp == 6 & more.com.climcha.resp.disagree == 1 ~ "Both oppose",
                                                          idprofpp == 5 & more.com.climcha.resp.disagree == 1 ~ "Politician favors/Citizen opposes",
                                                          idprofpp == 6 & more.com.climcha.resp.agree == 1 ~ "Politician opposes/Citizen favors")) 
FGN$samepp.more.com.climcha <- as.factor(FGN$samepp.more.com.climcha)

#raise.fuel.price
FGN <- FGN %>% mutate(Politician.Policy.Position.raise.fuel.price = case_when(idprofpp == 7 ~ "raise.fuel.price politician agrees",
                                                                             idprofpp == 8 ~ "raise.fuel.price politician disagrees")) 
FGN$Politician.Policy.Position.raise.fuel.price <- as.factor(FGN$Politician.Policy.Position.raise.fuel.price)

FGN <- FGN %>% mutate(Citizen.Policy.Position.raise.fuel.price = case_when(raise.fuel.price.resp.agree == 1 ~ "raise.fuel.price citizen agrees",
                                                                          raise.fuel.price.resp.disagree == 1 ~ "raise.fuel.price citizen disagrees")) 
FGN$Citizen.Policy.Position.raise.fuel.price <- as.factor(FGN$Citizen.Policy.Position.raise.fuel.price)

FGN <- FGN %>% mutate(samepp.raise.fuel.price = case_when(idprofpp == 7 & raise.fuel.price.resp.agree == 1 ~ "Both favor",
                                                          idprofpp == 8 & raise.fuel.price.resp.disagree == 1 ~ "Both oppose",
                                                          idprofpp == 7 & raise.fuel.price.resp.disagree == 1 ~ "Politician favors/Citizen opposes",
                                                          idprofpp == 8 & raise.fuel.price.resp.agree == 1 ~ "Politician opposes/Citizen favors")) 
FGN$samepp.raise.fuel.price <- as.factor(FGN$samepp.raise.fuel.price)

#immigrants.R.asset
FGN <- FGN %>% mutate(Politician.Policy.Position.immigrants.R.asset = case_when(idprofpp == 9 ~ "immigrants.R.asset politician agrees",
                                                                             idprofpp == 10 ~ "immigrants.R.asset politician disagrees")) 
FGN$Politician.Policy.Position.immigrants.R.asset <- as.factor(FGN$Politician.Policy.Position.immigrants.R.asset)

FGN <- FGN %>% mutate(Citizen.Policy.Position.immigrants.R.asset = case_when(immigrants.R.asset.resp.agree == 1 ~ "immigrants.R.asset citizen agrees",
                                                                          immigrants.R.asset.resp.disagree == 1 ~ "immigrants.R.asset citizen disagrees")) 
FGN$Citizen.Policy.Position.immigrants.R.asset <- as.factor(FGN$Citizen.Policy.Position.immigrants.R.asset)

FGN <- FGN %>% mutate(samepp.immigrants.R.asset = case_when(idprofpp == 9 & immigrants.R.asset.resp.agree == 1 ~ "Both favor",
                                                            idprofpp ==10 & immigrants.R.asset.resp.disagree == 1 ~ "Both oppose",
                                                            idprofpp == 9 & immigrants.R.asset.resp.disagree == 1 ~ "Politician favors/Citizen opposes",
                                                            idprofpp ==10 & immigrants.R.asset.resp.agree == 1 ~ "Politician opposes/Citizen favors")) 
FGN$samepp.immigrants.R.asset <- as.factor(FGN$samepp.immigrants.R.asset)

#islam.not.restricted
FGN <- FGN %>% mutate(Politician.Policy.Position.islam.not.restricted = case_when(idprofpp == 11 ~ "islam.not.restricted politician agrees",
                                                                             idprofpp == 12 ~ "islam.not.restricted politician disagrees")) 
FGN$Politician.Policy.Position.islam.not.restricted <- as.factor(FGN$Politician.Policy.Position.islam.not.restricted)

FGN <- FGN %>% mutate(Citizen.Policy.Position.islam.not.restricted = case_when(islam.not.restricted.resp.agree == 1 ~ "islam.not.restricted citizen agrees",
                                                                          islam.not.restricted.resp.disagree == 1 ~ "islam.not.restricted citizen disagrees")) 
FGN$Citizen.Policy.Position.islam.not.restricted <- as.factor(FGN$Citizen.Policy.Position.islam.not.restricted)

FGN <- FGN %>% mutate(samepp.islam.not.restricted = case_when(idprofpp ==11 & islam.not.restricted.resp.agree == 1 ~ "Both favor",
                                                              idprofpp ==12 & islam.not.restricted.resp.disagree == 1 ~ "Both oppose",
                                                              idprofpp ==11 & islam.not.restricted.resp.disagree == 1 ~ "Politician favors/Citizen opposes",
                                                              idprofpp ==12 & islam.not.restricted.resp.agree == 1 ~ "Politician opposes/Citizen favors")) 
FGN$samepp.islam.not.restricted <- as.factor(FGN$samepp.islam.not.restricted)

#equal.pay.by.law
FGN <- FGN %>% mutate(Politician.Policy.Position.equal.pay.by.law = case_when(idprofpp == 13 ~ "equal.pay.by.law politician agrees",
                                                                             idprofpp == 14 ~ "equal.pay.by.law politician disagrees")) 
FGN$Politician.Policy.Position.equal.pay.by.law <- as.factor(FGN$Politician.Policy.Position.equal.pay.by.law)

FGN <- FGN %>% mutate(Citizen.Policy.Position.equal.pay.by.law = case_when(equal.pay.by.law.resp.agree == 1 ~ "equal.pay.by.law citizen agrees",
                                                                          equal.pay.by.law.resp.disagree == 1 ~ "equal.pay.by.law citizen disagrees")) 
FGN$Citizen.Policy.Position.equal.pay.by.law <- as.factor(FGN$Citizen.Policy.Position.equal.pay.by.law)

FGN <- FGN %>% mutate(samepp.equal.pay.by.law = case_when(idprofpp == 13 & equal.pay.by.law.resp.agree == 1 ~ "Both favor",
                                                          idprofpp == 14 & equal.pay.by.law.resp.disagree == 1 ~ "Both oppose",
                                                          idprofpp == 13 & equal.pay.by.law.resp.disagree == 1 ~ "Politician favors/Citizen opposes",
                                                          idprofpp == 14 & equal.pay.by.law.resp.agree == 1 ~ "Politician opposes/Citizen favors")) 
FGN$samepp.equal.pay.by.law <- as.factor(FGN$samepp.equal.pay.by.law)

#homoco.may.adopt
FGN <- FGN %>% mutate(Politician.Policy.Position.homoco.may.adopt = case_when(idprofpp == 16 ~ "homoco.may.adopt politician agrees",
                                                                             idprofpp == 15 ~ "homoco.may.adopt politician disagrees")) 
FGN$Politician.Policy.Position.homoco.may.adopt <- as.factor(FGN$Politician.Policy.Position.homoco.may.adopt)

FGN <- FGN %>% mutate(Citizen.Policy.Position.homoco.may.adopt = case_when(homoco.may.adopt.resp.agree == 1 ~ "homoco.may.adopt citizen agrees",
                                                                          homoco.may.adopt.resp.disagree == 1 ~ "homoco.may.adopt citizen disagrees")) 
FGN$Citizen.Policy.Position.homoco.may.adopt <- as.factor(FGN$Citizen.Policy.Position.homoco.may.adopt)

FGN <- FGN %>% mutate(samepp.homoco.may.adopt = case_when(idprofpp ==16 & homoco.may.adopt.resp.agree == 1 ~ "Both favor",
                                                          idprofpp ==15 & homoco.may.adopt.resp.disagree == 1 ~ "Both oppose",
                                                          idprofpp ==16 & homoco.may.adopt.resp.disagree == 1 ~ "Politician favors/Citizen opposes",
                                                          idprofpp ==15 & homoco.may.adopt.resp.agree == 1 ~ "Politician opposes/Citizen favors")) 
FGN$samepp.homoco.may.adopt <- as.factor(FGN$samepp.homoco.may.adopt)

#------------------------------------#
#--- SAME PP rel mig gen variable ---#
#------------------------------------#

#samepp
FGN <- FGN %>% mutate(samepp = case_when(idprofpp == 1 & tax.rich.higher.resp.agree == 1 ~ "policy agreement",
                                         idprofpp == 2 & tax.rich.higher.resp.disagree == 1 ~ "policy agreement",
                                         idprofpp == 1 & tax.rich.higher.resp.agree == 0 ~ "policy disagreement",
                                         idprofpp == 2 & tax.rich.higher.resp.disagree == 0 ~ "policy disagreement",
                                         
                                         idprofpp == 3 & raise.supp.unemp.resp.agree == 1 ~ "policy agreement",
                                         idprofpp == 4 & raise.supp.unemp.resp.disagree == 1 ~ "policy agreement",
                                         idprofpp == 3 & raise.supp.unemp.resp.agree == 0 ~ "policy disagreement",
                                         idprofpp == 4 & raise.supp.unemp.resp.disagree == 0 ~ "policy disagreement",
                                         
                                         idprofpp == 5 & more.com.climcha.resp.agree == 1 ~ "policy agreement",
                                         idprofpp == 6 & more.com.climcha.resp.disagree == 1 ~ "policy agreement",
                                         idprofpp == 5 & more.com.climcha.resp.agree == 0 ~ "policy disagreement",
                                         idprofpp == 6 & more.com.climcha.resp.disagree == 0 ~ "policy disagreement",
                                         
                                         idprofpp == 7 & raise.fuel.price.resp.agree == 1 ~ "policy agreement",
                                         idprofpp == 8 & raise.fuel.price.resp.disagree == 1 ~ "policy agreement",
                                         idprofpp == 7 & raise.fuel.price.resp.agree == 0 ~ "policy disagreement",
                                         idprofpp == 8 & raise.fuel.price.resp.disagree == 0 ~ "policy disagreement",
                                         
                                         idprofpp == 9 & immigrants.R.asset.resp.agree == 1 ~ "policy agreement",
                                         idprofpp == 10 & immigrants.R.asset.resp.disagree == 1 ~ "policy agreement",
                                         idprofpp == 9 & immigrants.R.asset.resp.agree == 0 ~ "policy disagreement",
                                         idprofpp == 10 & immigrants.R.asset.resp.disagree == 0 ~ "policy disagreement",
                                         
                                         idprofpp == 11 & islam.not.restricted.resp.agree == 1 ~ "policy agreement",
                                         idprofpp == 12 & islam.not.restricted.resp.disagree == 1 ~ "policy agreement",
                                         idprofpp == 11 & islam.not.restricted.resp.agree == 0 ~ "policy disagreement",
                                         idprofpp == 12 & islam.not.restricted.resp.disagree == 0 ~ "policy disagreement",
                                         
                                         idprofpp == 13 & equal.pay.by.law.resp.agree == 1 ~ "policy agreement",
                                         idprofpp == 14 & equal.pay.by.law.resp.disagree == 1 ~ "policy agreement",
                                         idprofpp == 13 & equal.pay.by.law.resp.agree == 0 ~ "policy disagreement",
                                         idprofpp == 14 & equal.pay.by.law.resp.disagree == 0 ~ "policy disagreement",
                                         
                                         idprofpp == 16 & homoco.may.adopt.resp.agree == 1 ~ "policy agreement",
                                         idprofpp == 15 & homoco.may.adopt.resp.disagree == 1 ~ "policy agreement",
                                         idprofpp == 16 & homoco.may.adopt.resp.agree == 0 ~ "policy disagreement",
                                         idprofpp == 15 & homoco.may.adopt.resp.disagree == 0 ~ "policy disagreement"))
FGN$samepp <- as.factor(FGN$samepp)

FGN <- FGN %>% mutate(samepp01 = case_when(samepp == "policy agreement" ~ 1,
                                         samepp == "policy disagreement" ~ 0))
FGN$samepp01 <- as.factor(FGN$samepp01)

#samepp.dk
FGN <- FGN %>% mutate(samepp.dk = case_when(idprofpp == 1 & tax.rich.higher.resp.dk == 1 ~ "don't know",
                                         idprofpp == 2 & tax.rich.higher.resp.dk == 1 ~ "don't know",
                                         
                                         idprofpp == 3 & raise.supp.unemp.resp.dk == 1 ~ "don't know",
                                         idprofpp == 4 & raise.supp.unemp.resp.dk == 1 ~ "don't know",
                                         
                                         idprofpp == 5 & more.com.climcha.resp.dk == 1 ~ "don't know",
                                         idprofpp == 6 & more.com.climcha.resp.dk == 1 ~ "don't know",
                                         
                                         idprofpp == 7 & raise.fuel.price.resp.dk == 1 ~ "don't know",
                                         idprofpp == 8 & raise.fuel.price.resp.dk == 1 ~ "don't know",
                                         
                                         idprofpp == 9 & immigrants.R.asset.resp.dk == 1 ~ "don't know",
                                         idprofpp == 10 & immigrants.R.asset.resp.dk == 1 ~ "don't know",
                                         
                                         idprofpp == 11 & islam.not.restricted.resp.dk == 1 ~ "don't know",
                                         idprofpp == 12 & islam.not.restricted.resp.dk == 1 ~ "don't know",
                                         
                                         idprofpp == 13 & equal.pay.by.law.resp.dk == 1 ~ "don't know",
                                         idprofpp == 14 & equal.pay.by.law.resp.dk == 1 ~ "don't know",
                                         
                                         idprofpp == 16 & homoco.may.adopt.resp.dk == 1 ~ "don't know",
                                         idprofpp == 15 & homoco.may.adopt.resp.dk == 1 ~ "don't know"))
FGN$samepp.dk <- as.factor(FGN$samepp.dk)

#level of...
FGN <- FGN %>% mutate(level.of.samepp = case_when(idprofpp == 1 ~ tax.rich.higher,
                                             idprofpp == 2 ~ 1-tax.rich.higher,
                                             
                                             idprofpp == 3 ~ raise.supp.unemp, 
                                             idprofpp == 4 ~ 1-raise.supp.unemp,
                                             
                                             idprofpp == 5 ~ more.com.climcha,
                                             idprofpp == 6 ~ 1-more.com.climcha,
                                             
                                             idprofpp == 7 ~ raise.fuel.price,
                                             idprofpp == 8 ~ 1-raise.fuel.price,
                                             
                                             idprofpp == 9 ~ immigrants.R.asset,
                                             idprofpp == 10 ~ 1-immigrants.R.asset,
                                             
                                             idprofpp == 11 ~ islam.not.restricted,
                                             idprofpp == 12 ~ 1-islam.not.restricted,
                                             
                                             idprofpp == 13 ~ equal.pay.by.law,
                                             idprofpp == 14 ~ 1-equal.pay.by.law,
                                             
                                             idprofpp == 16 ~ homoco.may.adopt,
                                             idprofpp == 15 ~ 1-homoco.may.adopt))
#tax.rich.higher
FGN <- FGN %>% mutate(level.of.samepp.tax.rich.higher = case_when(idprofpp == 1 ~ tax.rich.higher,
                                                                  idprofpp == 2 ~ 1-tax.rich.higher))
#raise.supp.unemp
FGN <- FGN %>% mutate(level.of.samepp.raise.supp.unemp = case_when(idprofpp == 3 ~ raise.supp.unemp, 
                                                                   idprofpp == 4 ~ 1-raise.supp.unemp))
#more.com.climcha
FGN <- FGN %>% mutate(level.of.samepp.more.com.climcha = case_when(idprofpp == 5 ~ more.com.climcha,
                                                                   idprofpp == 6 ~ 1-more.com.climcha))
#raise.fuel.price
FGN <- FGN %>% mutate(level.of.samepp.raise.fuel.price = case_when(idprofpp == 7 ~ raise.fuel.price,
                                                                   idprofpp == 8 ~ 1-raise.fuel.price))
#immigrants.R.asset
FGN <- FGN %>% mutate(level.of.samepp.immigrants.R.asset = case_when(idprofpp == 9 ~ immigrants.R.asset,
                                                                     idprofpp == 10 ~ 1-immigrants.R.asset))
#islam.not.restricted
FGN <- FGN %>% mutate(level.of.samepp.islam.not.restricted = case_when(idprofpp == 11 ~ islam.not.restricted,
                                                                       idprofpp == 12 ~ 1-islam.not.restricted))
#equal.pay.by.law
FGN <- FGN %>% mutate(level.of.samepp.equal.pay.by.law = case_when(idprofpp == 13 ~ equal.pay.by.law,
                                                                   idprofpp == 14 ~ 1-equal.pay.by.law))
#homoco.may.adopt
FGN <- FGN %>% mutate(level.of.samepp.homoco.may.adopt = case_when(idprofpp == 16 ~ homoco.may.adopt,
                                                                   idprofpp == 15 ~ 1-homoco.may.adopt))
#pol agrees or disagrees? 
#equal.pay.by.law
FGN <- FGN %>% mutate(pol.agree.level.of.samepp.equal.pay.by.law = case_when(idprofpp == 13 ~ equal.pay.by.law))
#equal.pay.by.law
FGN <- FGN %>% mutate(pol.disagree.level.of.samepp.equal.pay.by.law = case_when(idprofpp == 14 ~ 1-equal.pay.by.law))
#homoco.may.adopt
FGN <- FGN %>% mutate(pol.agree.level.of.samepp.homoco.may.adopt = case_when(idprofpp == 16 ~ homoco.may.adopt))
#homoco.may.adopt
FGN <- FGN %>% mutate(pol.disagree.level.of.samepp.homoco.may.adopt = case_when(idprofpp == 15 ~ 1-homoco.may.adopt))


#Religion
FGN <- FGN %>% mutate(Citizen.Religion2 = case_when(binidrel2 == "Muslim" ~ "Muslim citizen",
                                                   binidrel2 == "Christian" ~ "Christian citizen",
                                                   binidrel2 == "Other" ~ "Other citizen",
                                                   binidrel2 == "Non-religious" ~ "non-religious citizen")) 
FGN <- FGN %>% mutate(samerel = case_when(Politician.Religion == "Muslim politician" & Citizen.Religion2 == "Muslim citizen" ~ "same",
                                          Politician.Religion == "Muslim politician" & Citizen.Religion2 == "Christian citizen" ~ "different",
                                          Politician.Religion == "Muslim politician" & Citizen.Religion2 == "non-religious citizen" ~ "different",
                                          Politician.Religion == "Muslim politician" & Citizen.Religion2 == "Other citizen" ~ "different",
                                          
                                          Politician.Religion == "Christian politician" & Citizen.Religion2 == "Muslim citizen" ~ "different",
                                          Politician.Religion == "Christian politician" & Citizen.Religion2 == "Christian citizen" ~ "same",
                                          Politician.Religion == "Christian politician" & Citizen.Religion2 == "non-religious citizen" ~ "different",
                                          Politician.Religion == "Christian politician" & Citizen.Religion2 == "Other citizen" ~ "different",
                                          
                                          Politician.Religion == "non-religious politician" & Citizen.Religion2 == "Muslim citizen" ~ "different",
                                          Politician.Religion == "non-religious politician" & Citizen.Religion2 == "Christian citizen" ~ "different",
                                          Politician.Religion == "non-religious politician" & Citizen.Religion2 == "non-religious citizen" ~ "same",
                                          Politician.Religion == "non-religious politician" & Citizen.Religion2 == "Other citizen" ~ "different"))
FGN$samerel <- as.factor(FGN$samerel)

#Ethnorace
FGN <- FGN %>% mutate(sameeth = case_when(idprofnogen == 1  & catrace == "France" ~ "different",
                                          idprofnogen == 2  & catrace == "France" ~ "different",
                                          idprofnogen == 3  & catrace == "France" ~ "different",
                                          
                                          idprofnogen == 4  & catrace == "France" ~ "different",
                                          idprofnogen == 5  & catrace == "France" ~ "different",
                                          idprofnogen == 6  & catrace == "France" ~ "different",
                                          
                                          idprofnogen == 7  & catrace == "France" ~ "different",
                                          idprofnogen == 8  & catrace == "France" ~ "different",
                                          idprofnogen == 9  & catrace == "France" ~ "different",
                                          
                                          idprofnogen == 10 & catrace == "France" ~ "same",
                                          idprofnogen == 11 & catrace == "France" ~ "same",
                                          idprofnogen == 12 & catrace == "France" ~ "same", 
                                          
                                          #
                                          idprofnogen == 1  & catrace == "German" ~ "different",
                                          idprofnogen == 2  & catrace == "German" ~ "different",
                                          idprofnogen == 3  & catrace == "German" ~ "different",
                                          
                                          idprofnogen == 4  & catrace == "German" ~ "different",
                                          idprofnogen == 5  & catrace == "German" ~ "different",
                                          idprofnogen == 6  & catrace == "German" ~ "different",
                                          
                                          idprofnogen == 7  & catrace == "German" ~ "different",
                                          idprofnogen == 8  & catrace == "German" ~ "different",
                                          idprofnogen == 9  & catrace == "German" ~ "different",
                                          
                                          idprofnogen == 10 & catrace == "German" ~ "same",
                                          idprofnogen == 11 & catrace == "German" ~ "same",
                                          idprofnogen == 12 & catrace == "German" ~ "same", 
                                          
                                          #
                                          idprofnogen == 1  & catrace == "Dutch" ~ "different",
                                          idprofnogen == 2  & catrace == "Dutch" ~ "different",
                                          idprofnogen == 3  & catrace == "Dutch" ~ "different",
                                          
                                          idprofnogen == 4  & catrace == "Dutch" ~ "different",
                                          idprofnogen == 5  & catrace == "Dutch" ~ "different",
                                          idprofnogen == 6  & catrace == "Dutch" ~ "different",
                                          
                                          idprofnogen == 7  & catrace == "Dutch" ~ "different",
                                          idprofnogen == 8  & catrace == "Dutch" ~ "different",
                                          idprofnogen == 9  & catrace == "Dutch" ~ "different",
                                          
                                          idprofnogen == 10 & catrace == "Dutch" ~ "same",
                                          idprofnogen == 11 & catrace == "Dutch" ~ "same",
                                          idprofnogen == 12 & catrace == "Dutch" ~ "same", 
                                          
                                          #
                                          idprofnogen == 1  & catrace == "Turkey" ~ "same",
                                          idprofnogen == 2  & catrace == "Turkey" ~ "same",
                                          idprofnogen == 3  & catrace == "Turkey" ~ "same",
                                          
                                          idprofnogen == 4  & catrace == "Turkey" ~ "different",
                                          idprofnogen == 5  & catrace == "Turkey" ~ "different",
                                          idprofnogen == 6  & catrace == "Turkey" ~ "different",
                                          
                                          idprofnogen == 7  & catrace == "Turkey" ~ "different",
                                          idprofnogen == 8  & catrace == "Turkey" ~ "different",
                                          idprofnogen == 9  & catrace == "Turkey" ~ "different",
                                          
                                          idprofnogen == 10 & catrace == "Turkey" ~ "different",
                                          idprofnogen == 11 & catrace == "Turkey" ~ "different",
                                          idprofnogen == 12 & catrace == "Turkey" ~ "different",
                                          
                                          #
                                          idprofnogen == 1  & catrace == "FSU" ~ "different",
                                          idprofnogen == 2  & catrace == "FSU" ~ "different",
                                          idprofnogen == 3  & catrace == "FSU" ~ "different",
                                          
                                          idprofnogen == 4  & catrace == "FSU" ~ "same",
                                          idprofnogen == 5  & catrace == "FSU" ~ "same",
                                          idprofnogen == 6  & catrace == "FSU" ~ "same",
                                          
                                          idprofnogen == 7  & catrace == "FSU" ~ "different",
                                          idprofnogen == 8  & catrace == "FSU" ~ "different",
                                          idprofnogen == 9  & catrace == "FSU" ~ "different",
                                          
                                          idprofnogen == 10 & catrace == "FSU" ~ "different",
                                          idprofnogen == 11 & catrace == "FSU" ~ "different",
                                          idprofnogen == 12 & catrace == "FSU" ~ "different",
                                          
                                          #
                                          idprofnogen == 1  & catrace == "Morocco" ~ "different",
                                          idprofnogen == 2  & catrace == "Morocco" ~ "different",
                                          idprofnogen == 3  & catrace == "Morocco" ~ "different",
                                          
                                          idprofnogen == 4  & catrace == "Morocco" ~ "same",
                                          idprofnogen == 5  & catrace == "Morocco" ~ "same",
                                          idprofnogen == 6  & catrace == "Morocco" ~ "same",
                                          
                                          idprofnogen == 7  & catrace == "Morocco" ~ "different",
                                          idprofnogen == 8  & catrace == "Morocco" ~ "different",
                                          idprofnogen == 9  & catrace == "Morocco" ~ "different",
                                          
                                          idprofnogen == 10 & catrace == "Morocco" ~ "different",
                                          idprofnogen == 11 & catrace == "Morocco" ~ "different",
                                          idprofnogen == 12 & catrace == "Morocco" ~ "different",
                                          
                                          #
                                          idprofnogen == 1  & catrace == "North-Africa" ~ "different",
                                          idprofnogen == 2  & catrace == "North-Africa" ~ "different",
                                          idprofnogen == 3  & catrace == "North-Africa" ~ "different",
                                          
                                          idprofnogen == 4  & catrace == "North-Africa" ~ "same",
                                          idprofnogen == 5  & catrace == "North-Africa" ~ "same",
                                          idprofnogen == 6  & catrace == "North-Africa" ~ "same",
                                          
                                          idprofnogen == 7  & catrace == "North-Africa" ~ "different",
                                          idprofnogen == 8  & catrace == "North-Africa" ~ "different",
                                          idprofnogen == 9  & catrace == "North-Africa" ~ "different",
                                          
                                          idprofnogen == 10 & catrace == "North-Africa" ~ "different",
                                          idprofnogen == 11 & catrace == "North-Africa" ~ "different",
                                          idprofnogen == 12 & catrace == "North-Africa" ~ "different",
                                          
                                          #
                                          idprofnogen == 1  & catrace == "Sub-Saharan Africa" ~ "different",
                                          idprofnogen == 2  & catrace == "Sub-Saharan Africa" ~ "different",
                                          idprofnogen == 3  & catrace == "Sub-Saharan Africa" ~ "different",
                                          
                                          idprofnogen == 4  & catrace == "Sub-Saharan Africa" ~ "different",
                                          idprofnogen == 5  & catrace == "Sub-Saharan Africa" ~ "different",
                                          idprofnogen == 6  & catrace == "Sub-Saharan Africa" ~ "different",
                                          
                                          idprofnogen == 7  & catrace == "Sub-Saharan Africa" ~ "same",
                                          idprofnogen == 8  & catrace == "Sub-Saharan Africa" ~ "same",
                                          idprofnogen == 9  & catrace == "Sub-Saharan Africa" ~ "same",
                                          
                                          idprofnogen == 10 & catrace == "Sub-Saharan Africa" ~ "different",
                                          idprofnogen == 11 & catrace == "Sub-Saharan Africa" ~ "different",
                                          idprofnogen == 12 & catrace == "Sub-Saharan Africa" ~ "different",
                                          
                                          #
                                          idprofnogen == 1  & catrace == "Surinam" ~ "different",
                                          idprofnogen == 2  & catrace == "Surinam" ~ "different",
                                          idprofnogen == 3  & catrace == "Surinam" ~ "different",
                                          
                                          idprofnogen == 4  & catrace == "Surinam" ~ "different",
                                          idprofnogen == 5  & catrace == "Surinam" ~ "different",
                                          idprofnogen == 6  & catrace == "Surinam" ~ "different",
                                          
                                          idprofnogen == 7  & catrace == "Surinam" ~ "same",
                                          idprofnogen == 8  & catrace == "Surinam" ~ "same",
                                          idprofnogen == 9  & catrace == "Surinam" ~ "same",
                                          
                                          idprofnogen == 10 & catrace == "Surinam" ~ "different",
                                          idprofnogen == 11 & catrace == "Surinam" ~ "different",
                                          idprofnogen == 12 & catrace == "Surinam" ~ "different",
                                          
                                          #
                                          idprofnogen == 1  & catrace == "Other" ~ "different",
                                          idprofnogen == 2  & catrace == "Other" ~ "different",
                                          idprofnogen == 3  & catrace == "Other" ~ "different",
                                          
                                          idprofnogen == 4  & catrace == "Other" ~ "different",
                                          idprofnogen == 5  & catrace == "Other" ~ "different",
                                          idprofnogen == 6  & catrace == "Other" ~ "different",
                                          
                                          idprofnogen == 7  & catrace == "Other" ~ "different",
                                          idprofnogen == 8  & catrace == "Other" ~ "different",
                                          idprofnogen == 9  & catrace == "Other" ~ "different",
                                          
                                          idprofnogen == 10 & catrace == "Other" ~ "different",
                                          idprofnogen == 11 & catrace == "Other" ~ "different",
                                          idprofnogen == 12 & catrace == "Other" ~ "different")) 
FGN$sameeth <- as.factor(FGN$sameeth)

#Gender
FGN <- FGN %>% mutate(samegen = case_when(Woman == 1 & Politician.Gender == "Female politician" ~ "same",
                                          Woman == 0 & Politician.Gender == "Male politician" ~ "same",
                                          Woman == 0 & Politician.Gender == "Female politician" ~ "different",
                                          Woman == 1 & Politician.Gender == "Male politician" ~ "different")) 
FGN$samegen <- as.factor(FGN$samegen)

#----------------#
#--- Analyses ---#
#----------------#

library("cregg")

#-----------#
#--- fig1---#
#-----------#

#NoMig.FR
FGN.NoMig.FR <- subset(FGN, Citizen.Ethnorace=="Citizen without migration background" & cntry=="France")
PolCit.Ethnorace.NoMig.FR <- mm(FGN.NoMig.FR, DVcho ~ Politician.Ethnorace,
                                id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.NoMig.FR

PolCit.Ethnorace.NoMig.FRDF <- data.frame(
  names= PolCit.Ethnorace.NoMig.FR$level,
  estimate=PolCit.Ethnorace.NoMig.FR$estimate*100,
  conf.low=PolCit.Ethnorace.NoMig.FR$lower*100,
  conf.high=PolCit.Ethnorace.NoMig.FR$upper*100)

PolCit.Ethnorace.NoMig.FRDF

PolCit.Ethnorace.NoMig.FRDF <- PolCit.Ethnorace.NoMig.FRDF %>% drop_na()

fig1Ethnorace.NoMig.FR <- ggplot(data = PolCit.Ethnorace.NoMig.FRDF, 
                                 aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "French voters with a background in:\n\nFrance only") +
  xlim(36, 66) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Mag.FR
FGN.Mag.FR <- subset(FGN, Citizen.Ethnorace=="North-African citizen (France)" & cntry=="France")
PolCit.Ethnorace.Mag.FR <- mm(FGN.Mag.FR, DVcho ~ Politician.Ethnorace,
                              id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.Mag.FR

PolCit.Ethnorace.Mag.FRDF <- data.frame(
  names= PolCit.Ethnorace.Mag.FR$level,
  estimate=PolCit.Ethnorace.Mag.FR$estimate*100,
  conf.low=PolCit.Ethnorace.Mag.FR$lower*100,
  conf.high=PolCit.Ethnorace.Mag.FR$upper*100)

PolCit.Ethnorace.Mag.FRDF

PolCit.Ethnorace.Mag.FRDF <- PolCit.Ethnorace.Mag.FRDF %>% drop_na()

fig1Ethnorace.Mag.FR <- ggplot(data = PolCit.Ethnorace.Mag.FRDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "North-Africa") +
  xlim(36, 66) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 

#SSA.FR
FGN.SSA.FR <- subset(FGN, Citizen.Ethnorace=="Sub-Saharan African citizen (France)" & cntry=="France")
PolCit.Ethnorace.SSA.FR <- mm(FGN.SSA.FR, DVcho ~ Politician.Ethnorace,
                              id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.SSA.FR

PolCit.Ethnorace.SSA.FRDF <- data.frame(
  names= PolCit.Ethnorace.SSA.FR$level,
  estimate=PolCit.Ethnorace.SSA.FR$estimate*100,
  conf.low=PolCit.Ethnorace.SSA.FR$lower*100,
  conf.high=PolCit.Ethnorace.SSA.FR$upper*100)

PolCit.Ethnorace.SSA.FRDF

PolCit.Ethnorace.SSA.FRDF <- PolCit.Ethnorace.SSA.FRDF %>% drop_na()

fig1Ethnorace.SSA.FR <- ggplot(data = PolCit.Ethnorace.SSA.FRDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Sub-Saharan Africa") +
  xlim(36, 66) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 

#Tur.FR
FGN.Tur.FR <- subset(FGN, Citizen.Ethnorace=="Turkish citizen" & cntry=="France")
PolCit.Ethnorace.Tur.FR <- mm(FGN.Tur.FR, DVcho ~ Politician.Ethnorace,
                              id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.Tur.FR

PolCit.Ethnorace.Tur.FRDF <- data.frame(
  names= PolCit.Ethnorace.Tur.FR$level,
  estimate=PolCit.Ethnorace.Tur.FR$estimate*100,
  conf.low=PolCit.Ethnorace.Tur.FR$lower*100,
  conf.high=PolCit.Ethnorace.Tur.FR$upper*100)

PolCit.Ethnorace.Tur.FRDF

PolCit.Ethnorace.Tur.FRDF <- PolCit.Ethnorace.Tur.FRDF %>% drop_na()

fig1Ethnorace.Tur.FR <- ggplot(data = PolCit.Ethnorace.Tur.FRDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Turkey") +
  xlim(36, 66) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig1Ethnorace.Tur.FR

fig1.France <- fig1Ethnorace.NoMig.FR/fig1Ethnorace.Mag.FR/fig1Ethnorace.SSA.FR/fig1Ethnorace.Tur.FR 
#fig1.France

#NoMig.DE
FGN.NoMig.DE <- subset(FGN, Citizen.Ethnorace=="Citizen without migration background" & cntry=="Germany")
PolCit.Ethnorace.NoMig.DE <- mm(FGN.NoMig.DE, DVcho ~ Politician.Ethnorace,
                                id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.NoMig.DE

PolCit.Ethnorace.NoMig.DEDF <- data.frame(
  names= PolCit.Ethnorace.NoMig.DE$level,
  estimate=PolCit.Ethnorace.NoMig.DE$estimate*100,
  conf.low=PolCit.Ethnorace.NoMig.DE$lower*100,
  conf.high=PolCit.Ethnorace.NoMig.DE$upper*100)

PolCit.Ethnorace.NoMig.DEDF

PolCit.Ethnorace.NoMig.DEDF <- PolCit.Ethnorace.NoMig.DEDF %>% drop_na()

fig1Ethnorace.NoMig.DE <- ggplot(data = PolCit.Ethnorace.NoMig.DEDF, 
                                 aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "German voters with a background in:\n\nGermany only") +
  xlim(36, 66) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#FSU.DE
FGN.FSU.DE <- subset(FGN, Citizen.Ethnorace=="FSU citizen (Germany)" & cntry=="Germany")
PolCit.Ethnorace.FSU.DE <- mm(FGN.FSU.DE, DVcho ~ Politician.Ethnorace,
                              id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.FSU.DE

PolCit.Ethnorace.FSU.DEDF <- data.frame(
  names= PolCit.Ethnorace.FSU.DE$level,
  estimate=PolCit.Ethnorace.FSU.DE$estimate*100,
  conf.low=PolCit.Ethnorace.FSU.DE$lower*100,
  conf.high=PolCit.Ethnorace.FSU.DE$upper*100)

PolCit.Ethnorace.FSU.DEDF

PolCit.Ethnorace.FSU.DEDF <- PolCit.Ethnorace.FSU.DEDF %>% drop_na()

fig1Ethnorace.FSU.DE <- ggplot(data = PolCit.Ethnorace.FSU.DEDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "The Former Soviet Union (FSU)") +
  xlim(36, 66) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 

#Tur.DE
FGN.Tur.DE <- subset(FGN, Citizen.Ethnorace=="Turkish citizen" & cntry=="Germany")
PolCit.Ethnorace.Tur.DE <- mm(FGN.Tur.DE, DVcho ~ Politician.Ethnorace,
                              id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.Tur.DE

PolCit.Ethnorace.Tur.DEDF <- data.frame(
  names= PolCit.Ethnorace.Tur.DE$level,
  estimate=PolCit.Ethnorace.Tur.DE$estimate*100,
  conf.low=PolCit.Ethnorace.Tur.DE$lower*100,
  conf.high=PolCit.Ethnorace.Tur.DE$upper*100)

PolCit.Ethnorace.Tur.DEDF

PolCit.Ethnorace.Tur.DEDF <- PolCit.Ethnorace.Tur.DEDF %>% drop_na()

fig1Ethnorace.Tur.DE <- ggplot(data = PolCit.Ethnorace.Tur.DEDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Turkey") +
  xlim(36, 66) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 

fig1.Germany <- fig1Ethnorace.NoMig.DE/fig1Ethnorace.FSU.DE/fig1Ethnorace.Tur.DE
#fig1.Germany

#NoMig.NL
FGN.NoMig.NL <- subset(FGN, Citizen.Ethnorace=="Citizen without migration background" & cntry=="Netherlands")
PolCit.Ethnorace.NoMig.NL <- mm(FGN.NoMig.NL, DVcho ~ Politician.Ethnorace,
                                id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.NoMig.NL

PolCit.Ethnorace.NoMig.NLDF <- data.frame(
  names= PolCit.Ethnorace.NoMig.NL$level,
  estimate=PolCit.Ethnorace.NoMig.NL$estimate*100,
  conf.low=PolCit.Ethnorace.NoMig.NL$lower*100,
  conf.high=PolCit.Ethnorace.NoMig.NL$upper*100)

PolCit.Ethnorace.NoMig.NLDF

PolCit.Ethnorace.NoMig.NLDF <- PolCit.Ethnorace.NoMig.NLDF %>% drop_na()

fig1Ethnorace.NoMig.NL <- ggplot(data = PolCit.Ethnorace.NoMig.NLDF, 
                                 aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Dutch voters with a background in:\n\nNetherlands only") +
  xlim(36, 66) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Mor.NL
FGN.Mor.NL <- subset(FGN, Citizen.Ethnorace=="Moroccan citizen (Netherlands)" & cntry=="Netherlands")
PolCit.Ethnorace.Mor.NL <- mm(FGN.Mor.NL, DVcho ~ Politician.Ethnorace,
                              id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.Mor.NL

PolCit.Ethnorace.Mor.NLDF <- data.frame(
  names= PolCit.Ethnorace.Mor.NL$level,
  estimate=PolCit.Ethnorace.Mor.NL$estimate*100,
  conf.low=PolCit.Ethnorace.Mor.NL$lower*100,
  conf.high=PolCit.Ethnorace.Mor.NL$upper*100)

PolCit.Ethnorace.Mor.NLDF

PolCit.Ethnorace.Mor.NLDF <- PolCit.Ethnorace.Mor.NLDF %>% drop_na()

fig1Ethnorace.Mor.NL <- ggplot(data = PolCit.Ethnorace.Mor.NLDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Morocco") +
  xlim(36, 66) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 

#Sur.NL
FGN.Sur.NL <- subset(FGN, Citizen.Ethnorace=="Surinamese citizen (Netherlands)" & cntry=="Netherlands")
PolCit.Ethnorace.Sur.NL <- mm(FGN.Sur.NL, DVcho ~ Politician.Ethnorace,
                              id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.Sur.NL

PolCit.Ethnorace.Sur.NLDF <- data.frame(
  names= PolCit.Ethnorace.Sur.NL$level,
  estimate=PolCit.Ethnorace.Sur.NL$estimate*100,
  conf.low=PolCit.Ethnorace.Sur.NL$lower*100,
  conf.high=PolCit.Ethnorace.Sur.NL$upper*100)

PolCit.Ethnorace.Sur.NLDF

PolCit.Ethnorace.Sur.NLDF <- PolCit.Ethnorace.Sur.NLDF %>% drop_na()

fig1Ethnorace.Sur.NL <- ggplot(data = PolCit.Ethnorace.Sur.NLDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Surinam") +
  xlim(36, 66) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 

#Tur.NL
FGN.Tur.NL <- subset(FGN, Citizen.Ethnorace=="Turkish citizen" & cntry=="Netherlands")
PolCit.Ethnorace.Tur.NL <- mm(FGN.Tur.NL, DVcho ~ Politician.Ethnorace,
                              id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.Tur.NL

PolCit.Ethnorace.Tur.NLDF <- data.frame(
  names= PolCit.Ethnorace.Tur.NL$level,
  estimate=PolCit.Ethnorace.Tur.NL$estimate*100,
  conf.low=PolCit.Ethnorace.Tur.NL$lower*100,
  conf.high=PolCit.Ethnorace.Tur.NL$upper*100)

PolCit.Ethnorace.Tur.NLDF

PolCit.Ethnorace.Tur.NLDF <- PolCit.Ethnorace.Tur.NLDF %>% drop_na()

fig1Ethnorace.Tur.NL <- ggplot(data = PolCit.Ethnorace.Tur.NLDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Turkey") +
  xlim(36, 66) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig1Ethnorace.Tur.NL

fig1.Netherlands <- fig1Ethnorace.NoMig.NL/fig1Ethnorace.Mor.NL/fig1Ethnorace.Sur.NL/fig1Ethnorace.Tur.NL
#fig1.Netherlands

fig1 <- (fig1.France | fig1.Germany | fig1.Netherlands) +
  plot_annotation(title = 'Voting likelihood when voter and politician share the same migration background:',
                  subtitle = ' ',
                  caption = "
                  Percentage of the vote, marginal means. Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they were most likely to vote for. Error bars represent
                  the 95% confidence interval. Clustered at the level of the respondent. I omitted results with citizens with 'other' migration backgrounds due to a low number of respondents in each category.") 
fig1
#ggsave(fig1, width = 11, height = 8, file="migration background doesnt matter.jpeg") 

#-------------#
#--- fig2  ---#
#-------------#

#NoMig.FGN
FGN.NoMig.FGN <- subset(FGN, MigBckgrnd==0)
PolCit.Ethnorace.NoMig.FGN <- mm(FGN.NoMig.FGN, DVcho ~ Politician.MigBckgrnd,
                                 id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.NoMig.FGN

PolCit.Ethnorace.NoMig.FGNDF <- data.frame(
  names= PolCit.Ethnorace.NoMig.FGN$level,
  estimate=PolCit.Ethnorace.NoMig.FGN$estimate*100,
  conf.low=PolCit.Ethnorace.NoMig.FGN$lower*100,
  conf.high=PolCit.Ethnorace.NoMig.FGN$upper*100)

PolCit.Ethnorace.NoMig.FGNDF

PolCit.Ethnorace.NoMig.FGNDF <- PolCit.Ethnorace.NoMig.FGNDF %>% drop_na()

fig2Ethnorace.NoMig.FGN <- ggplot(data = PolCit.Ethnorace.NoMig.FGNDF, 
                                  aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Voters without migration background +") +
  xlim(43, 57) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Mig.FGN
FGN.Mig.FGN <- subset(FGN, MigBckgrnd==1)
PolCit.Ethnorace.Mig.FGN <- mm(FGN.Mig.FGN, DVcho ~ Politician.MigBckgrnd,
                               id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Ethnorace.Mig.FGN

PolCit.Ethnorace.Mig.FGNDF <- data.frame(
  names= PolCit.Ethnorace.Mig.FGN$level,
  estimate=PolCit.Ethnorace.Mig.FGN$estimate*100,
  conf.low=PolCit.Ethnorace.Mig.FGN$lower*100,
  conf.high=PolCit.Ethnorace.Mig.FGN$upper*100)

PolCit.Ethnorace.Mig.FGNDF

PolCit.Ethnorace.Mig.FGNDF <- PolCit.Ethnorace.Mig.FGNDF %>% drop_na()

fig2Ethnorace.Mig.FGN <- ggplot(data = PolCit.Ethnorace.Mig.FGNDF, 
                                aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Voters with migration background +") +
  xlim(43, 57) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig2Ethnorace.Mig.FGN

fig2 <- fig2Ethnorace.Mig.FGN/fig2Ethnorace.NoMig.FGN +
  plot_annotation(title = 'Voting likelihood by whether voter or politician have a migration background:',
                  subtitle = ' ',
                  caption = "
                  Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they were most likely to vote for. 
                  Error bars represent the 95% confidence interval. Stacked data from France, Germany and the Netherlands. Weighted the subset with a 
                  migration background relative to their share of the population in France, Germany and the Netherlands. Clustered at the level of the respondent.") 
fig2
#ggsave(fig2, width = 8, height = 6, file="voters with a migration background prefer outgroup.jpeg") 

#-------------------------------#
#--- fig3 WHEN same religion ---#
#-------------------------------#

#France
#Muslim
FGN.Muslim.FRcit <- subset(FGN, Citizen.Religion=="Muslim citizen" & cntry== "France")
FGN.Muslim.FRcit$PolFRcit.Religion.Muslim <- 
  interaction(FGN.Muslim.FRcit$Politician.Religion, sep = " + ")
PolFRcit.Religion.Muslim <- mm(FGN.Muslim.FRcit, DVcho ~ PolFRcit.Religion.Muslim,
                               id = ~ INTNR, h0 = 0.5)
PolFRcit.Religion.Muslim

PolFRcit.Muslim.FRcitDF <- data.frame(
  names=PolFRcit.Religion.Muslim$level,
  estimate=PolFRcit.Religion.Muslim$estimate*100,
  conf.low=PolFRcit.Religion.Muslim$lower*100,
  conf.high=PolFRcit.Religion.Muslim$upper*100)

PolFRcit.Muslim.FRcitDF

fig3Muslim.FRcit <- ggplot(data = PolFRcit.Muslim.FRcitDF, 
                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("France:\n\nMuslim French voter +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

##Christian
#FGN.Christian.FRcit <- subset(FGN, Citizen.Religion=="Christian citizen"  & cntry== "France")
#FGN.Christian.FRcit$PolFRcit.Religion.Christian <- 
#  interaction(FGN.Christian.FRcit$Politician.Religion, sep = " + ")
#PolFRcit.Religion.Christian <- mm(FGN.Christian.FRcit, DVcho ~ PolFRcit.Religion.Christian,
#                                  id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
#PolFRcit.Religion.Christian
#
#PolFRcit.Christian.FRcitDF <- data.frame(
#  names=PolFRcit.Religion.Christian$level,
#  estimate=PolFRcit.Religion.Christian$estimate*100,
#  conf.low=PolFRcit.Religion.Christian$lower*100,
#  conf.high=PolFRcit.Religion.Christian$upper*100)
#
#PolFRcit.Christian.FRcitDF
#
#fig3Christian.FRcit <- ggplot(data = PolFRcit.Christian.FRcitDF, 
#                              aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
#  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
#  theme_minimal() +
#  ggtitle("Christian French voter +") +
#  ylab(" ") + 
#  xlab(" ") + 
#  xlim(14, 86) +
#  geom_vline(xintercept = 50) + 
#  theme(plot.title.position = "plot")

#Non-religious
FGN.NonRel.FRcit <- subset(FGN, Citizen.Religion=="non-religious citizen" & cntry== "France")
FGN.NonRel.FRcit$PolFRcit.Religion.NonRel <- 
  interaction(FGN.NonRel.FRcit$Politician.Religion, sep = " + ")
PolFRcit.Religion.NonRel <- mm(FGN.NonRel.FRcit, DVcho ~ PolFRcit.Religion.NonRel,
                               id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolFRcit.Religion.NonRel

PolFRcit.NonRel.FRcitDF <- data.frame(
  names=PolFRcit.Religion.NonRel$level,
  estimate=PolFRcit.Religion.NonRel$estimate*100,
  conf.low=PolFRcit.Religion.NonRel$lower*100,
  conf.high=PolFRcit.Religion.NonRel$upper*100)

PolFRcit.NonRel.FRcitDF

fig3NonRel.FRcit <- ggplot(data = PolFRcit.NonRel.FRcitDF, 
                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious French voter +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")


Fig3FR <- fig3Muslim.FRcit/fig3Christian.FRcit/fig3NonRel.FRcit +
  plot_annotation(title = 'France:',
                  subtitle = ' ',
                  caption = " ") 
#Germany
#Muslim
FGN.Muslim.DEcit <- subset(FGN, Citizen.Religion=="Muslim citizen" & cntry== "Germany")
FGN.Muslim.DEcit$PolDEcit.Religion.Muslim <- 
  interaction(FGN.Muslim.DEcit$Politician.Religion, sep = " + ")
PolDEcit.Religion.Muslim <- mm(FGN.Muslim.DEcit, DVcho ~ PolDEcit.Religion.Muslim,
                               id = ~ INTNR, h0 = 0.5)
PolDEcit.Religion.Muslim

PolDEcit.Muslim.DEcitDF <- data.frame(
  names=PolDEcit.Religion.Muslim$level,
  estimate=PolDEcit.Religion.Muslim$estimate*100,
  conf.low=PolDEcit.Religion.Muslim$lower*100,
  conf.high=PolDEcit.Religion.Muslim$upper*100)

PolDEcit.Muslim.DEcitDF

fig3Muslim.DEcit <- ggplot(data = PolDEcit.Muslim.DEcitDF, 
                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Germany:\n\nMuslim German voter +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

##Christian
#FGN.Christian.DEcit <- subset(FGN, Citizen.Religion=="Christian citizen"  & cntry== "Germany")
#FGN.Christian.DEcit$PolDEcit.Religion.Christian <- 
#  interaction(FGN.Christian.DEcit$Politician.Religion, sep = " + ")
#PolDEcit.Religion.Christian <- mm(FGN.Christian.DEcit, DVcho ~ PolDEcit.Religion.Christian,
#                                  id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
#PolDEcit.Religion.Christian
#
#PolDEcit.Christian.DEcitDF <- data.frame(
#  names=PolDEcit.Religion.Christian$level,
#  estimate=PolDEcit.Religion.Christian$estimate*100,
#  conf.low=PolDEcit.Religion.Christian$lower*100,
#  conf.high=PolDEcit.Religion.Christian$upper*100)
#
#PolDEcit.Christian.DEcitDF
#
#fig3Christian.DEcit <- ggplot(data = PolDEcit.Christian.DEcitDF, 
#                              aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
#  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
#  theme_minimal() +
#  ggtitle("Christian German voter +") +
#  ylab(" ") + 
#  xlab(" ") + 
#  xlim(14, 86) +
#  geom_vline(xintercept = 50) + 
#  theme(plot.title.position = "plot")

#Non-religious
FGN.NonRel.DEcit <- subset(FGN, Citizen.Religion=="non-religious citizen" & cntry== "Germany")
FGN.NonRel.DEcit$PolDEcit.Religion.NonRel <- 
  interaction(FGN.NonRel.DEcit$Politician.Religion, sep = " + ")
PolDEcit.Religion.NonRel <- mm(FGN.NonRel.DEcit, DVcho ~ PolDEcit.Religion.NonRel,
                               id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolDEcit.Religion.NonRel

PolDEcit.NonRel.DEcitDF <- data.frame(
  names=PolDEcit.Religion.NonRel$level,
  estimate=PolDEcit.Religion.NonRel$estimate*100,
  conf.low=PolDEcit.Religion.NonRel$lower*100,
  conf.high=PolDEcit.Religion.NonRel$upper*100)

PolDEcit.NonRel.DEcitDF

fig3NonRel.DEcit <- ggplot(data = PolDEcit.NonRel.DEcitDF, 
                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious German voter +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Netherlands
#Muslim
FGN.Muslim.NLcit <- subset(FGN, Citizen.Religion=="Muslim citizen" & cntry== "Netherlands")
FGN.Muslim.NLcit$PolNLcit.Religion.Muslim <- 
  interaction(FGN.Muslim.NLcit$Politician.Religion, sep = " + ")
PolNLcit.Religion.Muslim <- mm(FGN.Muslim.NLcit, DVcho ~ PolNLcit.Religion.Muslim,
                               id = ~ INTNR, h0 = 0.5)
PolNLcit.Religion.Muslim

PolNLcit.Muslim.NLcitDF <- data.frame(
  names=PolNLcit.Religion.Muslim$level,
  estimate=PolNLcit.Religion.Muslim$estimate*100,
  conf.low=PolNLcit.Religion.Muslim$lower*100,
  conf.high=PolNLcit.Religion.Muslim$upper*100)

PolNLcit.Muslim.NLcitDF

fig3Muslim.NLcit <- ggplot(data = PolNLcit.Muslim.NLcitDF, 
                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Netherlands:\n\nMuslim Dutch voter +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

##Christian
#FGN.Christian.NLcit <- subset(FGN, Citizen.Religion=="Christian citizen"  & cntry== "Netherlands")
#FGN.Christian.NLcit$PolNLcit.Religion.Christian <- 
#  interaction(FGN.Christian.NLcit$Politician.Religion, sep = " + ")
#PolNLcit.Religion.Christian <- mm(FGN.Christian.NLcit, DVcho ~ PolNLcit.Religion.Christian,
#                                  id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
#PolNLcit.Religion.Christian
#
#PolNLcit.Christian.NLcitDF <- data.frame(
#  names=PolNLcit.Religion.Christian$level,
#  estimate=PolNLcit.Religion.Christian$estimate*100,
#  conf.low=PolNLcit.Religion.Christian$lower*100,
#  conf.high=PolNLcit.Religion.Christian$upper*100)
#
#PolNLcit.Christian.NLcitDF
#
#fig3Christian.NLcit <- ggplot(data = PolNLcit.Christian.NLcitDF, 
#                              aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
#  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
#  theme_minimal() +
#  ggtitle("Christian Dutch voter +") +
#  ylab(" ") + 
#  xlab(" ") + 
#  xlim(14, 86) +
#  geom_vline(xintercept = 50) + 
#  theme(plot.title.position = "plot")

#Non-religious
FGN.NonRel.NLcit <- subset(FGN, Citizen.Religion=="non-religious citizen" & cntry== "Netherlands")
FGN.NonRel.NLcit$PolNLcit.Religion.NonRel <- 
  interaction(FGN.NonRel.NLcit$Politician.Religion, sep = " + ")
PolNLcit.Religion.NonRel <- mm(FGN.NonRel.NLcit, DVcho ~ PolNLcit.Religion.NonRel,
                               id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolNLcit.Religion.NonRel

PolNLcit.NonRel.NLcitDF <- data.frame(
  names=PolNLcit.Religion.NonRel$level,
  estimate=PolNLcit.Religion.NonRel$estimate*100,
  conf.low=PolNLcit.Religion.NonRel$lower*100,
  conf.high=PolNLcit.Religion.NonRel$upper*100)

PolNLcit.NonRel.NLcitDF

fig3NonRel.NLcit <- ggplot(data = PolNLcit.NonRel.NLcitDF, 
                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious Dutch voter +") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

Fig3 <- fig3Muslim.FRcit/fig3NonRel.FRcit/fig3Muslim.DEcit/fig3NonRel.DEcit/fig3Muslim.NLcit/fig3NonRel.NLcit +
  plot_annotation(title = 'Voting likelihood when voter and politician share the same religion:',
                  subtitle = ' ',
                  caption = "
                  Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they are most likely to vote for. Error bars
                  represent the 95% confidence interval. I weighted Christian and non-religious subsets on migration background, I clustered confidence intervals 
                  at the level of the respondent.") 

Fig3
#ggsave(Fig3, width = 8, height = 12, file="religion matters a lot.jpeg")

#------------#
#--- fig4 ---#
#------------#

FGN$PolCit.Gender <- 
  interaction(FGN$Citizen.Gender, FGN$Politician.Gender, sep = " + ")
PolCit.Gender <- mm(FGN, DVcho ~ PolCit.Gender,
                    id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Gender

PolCit.GenderDF <- data.frame(
  names=PolCit.Gender$level,
  estimate=PolCit.Gender$estimate*100,
  conf.low=PolCit.Gender$lower*100,
  conf.high=PolCit.Gender$upper*100,
  number=c("001", "004", "003", "002"))

PolCit.GenderDF

fig4Gender <- ggplot(data = PolCit.GenderDF, 
                     aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

library("patchwork") #PolCit.GenderDF
fig4 <- fig4Gender +
  plot_annotation(title = 'Voting likelihood when voter and politician share the same gender:',
                  subtitle = ' ',
                  caption = "
Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they were most likely to vote for. 
                  Due to similar results in each country, I stacked the data from France, Germany and the Netherlands. 
                  Error bars represent the 95% confidence interval. Weighted on migration background.") 
fig4 
#ggsave(fig4, width = 8, height = 4, file="no gender affinity effect.jpeg") 

#------------#
#--- fig5 ---# 
#------------#
FGN$samepp
#Policy.Position.samepp H4
PolCit.samepp <- mm(FGN, DVcho ~ samepp,
                    id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.sameppDF <- data.frame(
  names=PolCit.samepp$level,
  estimate=PolCit.samepp$estimate*100,
  conf.low=PolCit.samepp$lower*100,
  conf.high=PolCit.samepp$upper*100,
  number=c("002", "001"))
fig5Policy.Position.samepp <- ggplot(data = PolCit.sameppDF, 
                                     aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Policy position") + 
  theme(plot.title.position = "plot")
#fig5Policy.Position.samepp

#Religion H2b
PolCit.samerel <- mm(FGN, DVcho ~ samerel,
                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.samerel
PolCit.ReligionDF <- data.frame(
  names=PolCit.samerel$level,
  estimate=PolCit.samerel$estimate*100,
  conf.low=PolCit.samerel$lower*100,
  conf.high=PolCit.samerel$upper*100,
  number=c("001", "002"))
fig5religion <- ggplot(data = PolCit.ReligionDF, 
               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Religion") + 
  theme(plot.title.position = "plot")
#fig5religion

#Ethnorace H2a
PolCit.sameeth <- mm(FGN, DVcho ~ sameeth,
                     id = ~ INTNR, h0 = 0.5)
PolCit.EthnoraceDF <- data.frame(
  names=PolCit.sameeth$level,
  estimate=PolCit.sameeth$estimate*100,
  conf.low=PolCit.sameeth$lower*100,
  conf.high=PolCit.sameeth$upper*100,
  number=c("001", "002"))
fig5Ethnorace <- ggplot(data = PolCit.EthnoraceDF, 
                       aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Migration background") + 
  theme(plot.title.position = "plot")
#fig5Ethnorace

#Gender H2c
PolCit.samegen <- mm(FGN, DVcho ~ samegen,
                     id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.GenderDF <- data.frame(
  names=PolCit.samegen$level,
  estimate=PolCit.samegen$estimate*100,
  conf.low=PolCit.samegen$lower*100,
  conf.high=PolCit.samegen$upper*100,
  number=c("001", "002"))
fig5Gender <- ggplot(data = PolCit.GenderDF, 
                        aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Gender") + 
  theme(plot.title.position = "plot")
#fig5Gender

library("patchwork")
fig5 <- fig5Policy.Position.samepp/fig5religion/fig5Ethnorace/fig5Gender +
  plot_annotation(title = 'Voting likelihood when voter and politician share the same:',
                  subtitle = ' ',
                  caption = "
                  Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they are most likely to vote for.
                  Error bars represent the 95% confidence interval. Weighted analyses on policy position, religion and gender on migration background.
                  Clustered confidence intervals at the level of the respondent.") 
fig5 
#ggsave(fig5, width = 8, height = 6, file="Overview.jpeg")   

#--------------------------------------#
#--- fig6 WHEN same policy position ---#
#--------------------------------------#

#policy positions
#tax.rich.higher
PolCit.Policy.Position.tax.rich.higher <- mm(FGN, DVcho ~ samepp.tax.rich.higher,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.tax.rich.higherDF <- data.frame(
  names=PolCit.Policy.Position.tax.rich.higher$level,
  estimate=PolCit.Policy.Position.tax.rich.higher$estimate*100,
  conf.low=PolCit.Policy.Position.tax.rich.higher$lower*100,
  conf.high=PolCit.Policy.Position.tax.rich.higher$upper*100,
  number=c("001", "002", "003", "004"))
PolCit.Policy.Position.tax.rich.higherDF
#raise.supp.unemp
PolCit.Policy.Position.raise.supp.unemp <- mm(FGN, DVcho ~ samepp.raise.supp.unemp,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.raise.supp.unempDF <- data.frame(
  names=PolCit.Policy.Position.raise.supp.unemp$level,
  estimate=PolCit.Policy.Position.raise.supp.unemp$estimate*100,
  conf.low=PolCit.Policy.Position.raise.supp.unemp$lower*100,
  conf.high=PolCit.Policy.Position.raise.supp.unemp$upper*100,
  number=c("001", "002", "003", "004"))
PolCit.Policy.Position.raise.supp.unempDF
#more.com.climcha
PolCit.Policy.Position.more.com.climcha <- mm(FGN, DVcho ~ samepp.more.com.climcha,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.more.com.climchaDF <- data.frame(
  names=PolCit.Policy.Position.more.com.climcha$level,
  estimate=PolCit.Policy.Position.more.com.climcha$estimate*100,
  conf.low=PolCit.Policy.Position.more.com.climcha$lower*100,
  conf.high=PolCit.Policy.Position.more.com.climcha$upper*100,
  number=c("001", "002", "003", "004"))
PolCit.Policy.Position.more.com.climchaDF
#raise.fuel.price
PolCit.Policy.Position.raise.fuel.price <- mm(FGN, DVcho ~ samepp.raise.fuel.price,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.raise.fuel.priceDF <- data.frame(
  names=PolCit.Policy.Position.raise.fuel.price$level,
  estimate=PolCit.Policy.Position.raise.fuel.price$estimate*100,
  conf.low=PolCit.Policy.Position.raise.fuel.price$lower*100,
  conf.high=PolCit.Policy.Position.raise.fuel.price$upper*100,
  number=c("001", "002", "003", "004"))
PolCit.Policy.Position.raise.fuel.priceDF
#immigrants.R.asset
PolCit.Policy.Position.immigrants.R.asset <- mm(FGN, DVcho ~ samepp.immigrants.R.asset,
                                                id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.immigrants.R.assetDF <- data.frame(
  names=PolCit.Policy.Position.immigrants.R.asset$level,
  estimate=PolCit.Policy.Position.immigrants.R.asset$estimate*100,
  conf.low=PolCit.Policy.Position.immigrants.R.asset$lower*100,
  conf.high=PolCit.Policy.Position.immigrants.R.asset$upper*100,
  number=c("001", "002", "003", "004"))
PolCit.Policy.Position.immigrants.R.assetDF
#islam.not.restricted
PolCit.Policy.Position.islam.not.restricted <- mm(FGN, DVcho ~ samepp.islam.not.restricted,
                                                  id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.islam.not.restrictedDF <- data.frame(
  names=PolCit.Policy.Position.islam.not.restricted$level,
  estimate=PolCit.Policy.Position.islam.not.restricted$estimate*100,
  conf.low=PolCit.Policy.Position.islam.not.restricted$lower*100,
  conf.high=PolCit.Policy.Position.islam.not.restricted$upper*100,
  number=c("001", "002", "003", "004"))
PolCit.Policy.Position.islam.not.restrictedDF
#equal.pay.by.law
PolCit.Policy.Position.equal.pay.by.law <- mm(FGN, DVcho ~ samepp.equal.pay.by.law,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.equal.pay.by.lawDF <- data.frame(
  names=PolCit.Policy.Position.equal.pay.by.law$level,
  estimate=PolCit.Policy.Position.equal.pay.by.law$estimate*100,
  conf.low=PolCit.Policy.Position.equal.pay.by.law$lower*100,
  conf.high=PolCit.Policy.Position.equal.pay.by.law$upper*100,
  number=c("001", "002", "003", "004"))
PolCit.Policy.Position.equal.pay.by.lawDF
#homoco.may.adopt
PolCit.Policy.Position.homoco.may.adopt <- mm(FGN, DVcho ~ samepp.homoco.may.adopt,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.homoco.may.adoptDF <- data.frame(
  names=PolCit.Policy.Position.homoco.may.adopt$level,
  estimate=PolCit.Policy.Position.homoco.may.adopt$estimate*100,
  conf.low=PolCit.Policy.Position.homoco.may.adopt$lower*100,
  conf.high=PolCit.Policy.Position.homoco.may.adopt$upper*100,
  number=c("001", "002", "003", "004"))
PolCit.Policy.Position.homoco.may.adoptDF

#--- Visualization

#tax.rich.higher
fig6.tax.rich.higher <- ggplot(data = PolCit.Policy.Position.tax.rich.higherDF, 
                               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14.25501, 88.84187) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Taxing the rich") + 
  theme(plot.title.position = "plot")
#fig6.tax.rich.higher

#raise.supp.unemp
fig6.raise.supp.unemp <- ggplot(data = PolCit.Policy.Position.raise.supp.unempDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14.25501, 88.84187) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Supporting the unemployed") + 
  theme(plot.title.position = "plot")
#fig6.raise.supp.unemp

#more.com.climcha
fig6.more.com.climcha <- ggplot(data = PolCit.Policy.Position.more.com.climchaDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14.25501, 88.84187) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Combatting climate change") + 
  theme(plot.title.position = "plot")
#fig6.more.com.climcha

#raise.fuel.price
fig6.raise.fuel.price <- ggplot(data = PolCit.Policy.Position.raise.fuel.priceDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14.25501, 88.84187) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Raising fuel prices") + 
  theme(plot.title.position = "plot")
#fig6.raise.fuel.price

#immigrants.R.asset
fig6.immigrants.R.asset <- ggplot(data = PolCit.Policy.Position.immigrants.R.assetDF, 
                                  aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14.25501, 88.84187) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Immigrants are an asset") + 
  theme(plot.title.position = "plot")
#fig6.immigrants.R.asset

#islam.not.restricted
fig6.islam.not.restricted <- ggplot(data = PolCit.Policy.Position.islam.not.restrictedDF, 
                                    aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14.25501, 88.84187) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Islam should not be restricted") + 
  theme(plot.title.position = "plot")
#fig6.islam.not.restricted

#equal.pay.by.law
fig6.equal.pay.by.law <- ggplot(data = PolCit.Policy.Position.equal.pay.by.lawDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14.25501, 88.84187) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Gender equality, equal pay") + 
  theme(plot.title.position = "plot")
#fig6.equal.pay.by.law

#homoco.may.adopt
fig6.homoco.may.adopt <- ggplot(data = PolCit.Policy.Position.homoco.may.adoptDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(14.25501, 88.84187) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Same-sex adoption") + 
  theme(plot.title.position = "plot")
#fig6.homoco.may.adopt

library("patchwork")
fig6 <- fig6.tax.rich.higher/
  fig6.raise.supp.unemp/
  fig6.more.com.climcha/
  fig6.raise.fuel.price/
  fig6.immigrants.R.asset/
  fig6.islam.not.restricted/
  fig6.equal.pay.by.law/
  fig6.homoco.may.adopt +
  plot_annotation(title = '\nVoting likelihood when voter and politician share the same policy position:',
                  subtitle = ' ',
                  caption = "
                  Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they are most likely to vote for. Error bars
                  represent the 95% confidence interval. Weighted on migration background, confidence intervals were clustered at the level of the respondent.") 
fig6 
#ggsave(fig6, width = 8, height = 12, file="policy positions matter the most to voters.jpeg")  

#------------#
#--- fig7 ---#
#------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")

shapes <- c("triangle", "square")
linetypes <- c("dashed", "solid")
#raise.supp.unemp
#mm
cit.NonRel.pol.NonRel.raise.supp.unemp <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.raise.supp.unemp,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.raise.supp.unemp <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.raise.supp.unemp,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.NonRel.raise.supp.unemp
cit.NonRel.pol.Mus.raise.supp.unemp
#making df
cit.NonRel.pol.NonRel.raise.supp.unempDF <- data.frame(
  names=cit.NonRel.pol.NonRel.raise.supp.unemp$level,
  estimate=cit.NonRel.pol.NonRel.raise.supp.unemp$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.raise.supp.unemp$lower*100,
  conf.high=cit.NonRel.pol.NonRel.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"), shapes="square")

cit.NonRel.pol.Mus.raise.supp.unempDF <- data.frame(
  names=cit.NonRel.pol.Mus.raise.supp.unemp$level,
  estimate=cit.NonRel.pol.Mus.raise.supp.unemp$estimate*100,
  conf.low=cit.NonRel.pol.Mus.raise.supp.unemp$lower*100,
  conf.high=cit.NonRel.pol.Mus.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"), shapes="triangle")

# Combine the two dataframes
raise.supp.unempDF <- rbind(cit.NonRel.pol.NonRel.raise.supp.unempDF, cit.NonRel.pol.Mus.raise.supp.unempDF)
raise.supp.unempDF <- raise.supp.unempDF[-c(2:4, 6:8), ]
raise.supp.unempDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig7.raise.supp.unemp <- ggplot(data = raise.supp.unempDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                               shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Supporting the unemployed") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(0, 95) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig7.raise.supp.unemp

#immigrants.R.asset
#mm
cit.NonRel.pol.NonRel.immigrants.R.asset <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.immigrants.R.asset,
                                               id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.immigrants.R.asset <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.immigrants.R.asset,
                                            id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.immigrants.R.assetDF <- data.frame(
  names=cit.NonRel.pol.NonRel.immigrants.R.asset$level,
  estimate=cit.NonRel.pol.NonRel.immigrants.R.asset$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.immigrants.R.asset$lower*100,
  conf.high=cit.NonRel.pol.NonRel.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"), shapes="square")

cit.NonRel.pol.Mus.immigrants.R.assetDF <- data.frame(
  names=cit.NonRel.pol.Mus.immigrants.R.asset$level,
  estimate=cit.NonRel.pol.Mus.immigrants.R.asset$estimate*100,
  conf.low=cit.NonRel.pol.Mus.immigrants.R.asset$lower*100,
  conf.high=cit.NonRel.pol.Mus.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"), shapes="triangle")

# Combine the two dataframes
immigrants.R.assetDF <- rbind(cit.NonRel.pol.NonRel.immigrants.R.assetDF, cit.NonRel.pol.Mus.immigrants.R.assetDF)
immigrants.R.assetDF <- immigrants.R.assetDF[-c(1:2, 4:6, 8:8), ]
immigrants.R.assetDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig7.immigrants.R.asset <- ggplot(data = immigrants.R.assetDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                                   shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Immigrants are an asset") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(0, 95) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig7.immigrants.R.asset

#islam.not.restricted
#mm
cit.NonRel.pol.NonRel.islam.not.restricted <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.islam.not.restricted,
                                                 id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.islam.not.restricted <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.islam.not.restricted,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.islam.not.restrictedDF <- data.frame(
  names=cit.NonRel.pol.NonRel.islam.not.restricted$level,
  estimate=cit.NonRel.pol.NonRel.islam.not.restricted$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.islam.not.restricted$lower*100,
  conf.high=cit.NonRel.pol.NonRel.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"), shapes="square")

cit.NonRel.pol.Mus.islam.not.restrictedDF <- data.frame(
  names=cit.NonRel.pol.Mus.islam.not.restricted$level,
  estimate=cit.NonRel.pol.Mus.islam.not.restricted$estimate*100,
  conf.low=cit.NonRel.pol.Mus.islam.not.restricted$lower*100,
  conf.high=cit.NonRel.pol.Mus.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"), shapes="triangle")

# Combine the two dataframes
islam.not.restrictedDF <- rbind(cit.NonRel.pol.NonRel.islam.not.restrictedDF, cit.NonRel.pol.Mus.islam.not.restrictedDF)
islam.not.restrictedDF <- islam.not.restrictedDF[-c(2:4, 6:8), ]
islam.not.restrictedDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig7.islam.not.restricted <- ggplot(data = islam.not.restrictedDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                                       shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Islam should not be restricted") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(0, 95) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig7.islam.not.restricted

#equal.pay.by.law
#mm
cit.NonRel.pol.NonRel.equal.pay.by.law <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.equal.pay.by.law <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.NonRel.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"), shapes="square")

cit.NonRel.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.Mus.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.Mus.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"), shapes="triangle")

# Combine the two dataframes
equal.pay.by.lawDF <- rbind(cit.NonRel.pol.NonRel.equal.pay.by.lawDF, cit.NonRel.pol.Mus.equal.pay.by.lawDF)
equal.pay.by.lawDF <- equal.pay.by.lawDF[-c(1:3, 5:7), ]
equal.pay.by.lawDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig7.equal.pay.by.law <- ggplot(data = equal.pay.by.lawDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                               shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Gender equality, equal pay") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(0, 95) +
  theme(plot.title.position = "plot", legend.position = "bottom") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig7.equal.pay.by.law

fig7 <- fig7.raise.supp.unemp/
  fig7.immigrants.R.asset/
  fig7.islam.not.restricted/
  fig7.equal.pay.by.law +
  plot_annotation(title = 'Non-religious voters:\nDifferences in voting likelihood between non-religious and Muslim politicians',
                  subtitle = ' ',
                  caption = "
Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they are most likely to vote for. Error
bars represent the 95% confidence interval. Weighted on migration background. Clustered confidence intervals at the level of the respondent.") 
fig7
#ggsave(fig7, width = 8, height = 6, file="hypocritical non-religious voters.jpeg")  

#----------------------------------------#
#--------------- Appendix ---------------#
#----------------------------------------#

#----------------------------------------------#
#--- fig7 Ranking the lovers and the haters ---#
#----------------------------------------------#

#Religion
#NonRel
FGN.NonRel.cit <- subset(FGN, Citizen.Religion=="non-religious citizen")
#tov Moslim
FGN.NonRel.cit.lm.cluster.refcatMuslim <- miceadds::lm.cluster(
  data=FGN.NonRel.cit, 
  formula = FGN.NonRel.cit$DVcho ~ 
    FGN.NonRel.cit$Age + FGN.NonRel.cit$AGE2 + FGN.NonRel.cit$Woman + FGN.NonRel.cit$Education + FGN.NonRel.cit$cntry + 
    FGN.NonRel.cit$Politician.is.Christ + FGN.NonRel.cit$Politician.is.NonRel,
  cluster=FGN.NonRel.cit$INTNR, 
  weights=FGN.NonRel.cit$w8eth)
summary(FGN.NonRel.cit.lm.cluster.refcatMuslim)
#tov Christian
FGN.NonRel.cit.lm.cluster.refcatChrist <- miceadds::lm.cluster(
  data=FGN.NonRel.cit, 
  formula = FGN.NonRel.cit$DVcho ~ 
    FGN.NonRel.cit$Age + FGN.NonRel.cit$AGE2 + FGN.NonRel.cit$Woman + FGN.NonRel.cit$Education + FGN.NonRel.cit$cntry +
    FGN.NonRel.cit$Politician.is.Muslim + FGN.NonRel.cit$Politician.is.NonRel,
  cluster=FGN.NonRel.cit$INTNR, 
  weights=FGN.NonRel.cit$w8eth)
summary(FGN.NonRel.cit.lm.cluster.refcatChrist)
#tov Non-rel
FGN.NonRel.cit.lm.cluster.refcatNonRel <- miceadds::lm.cluster(
  data=FGN.NonRel.cit, 
  formula = FGN.NonRel.cit$DVcho ~ 
    FGN.NonRel.cit$Age + FGN.NonRel.cit$AGE2 + FGN.NonRel.cit$Woman + FGN.NonRel.cit$Education + FGN.NonRel.cit$cntry +
    FGN.NonRel.cit$Politician.is.Muslim + FGN.NonRel.cit$Politician.is.Christ,
  cluster=FGN.NonRel.cit$INTNR, 
  weights=FGN.NonRel.cit$w8eth)
summary(FGN.NonRel.cit.lm.cluster.refcatNonRel)

##Christ
#FGN.Christ.cit <- subset(FGN, Citizen.Religion=="Christian citizen")
##tov Moslim
#FGN.Christ.cit.lm.cluster.refcatMuslim <- miceadds::lm.cluster(
#  data=FGN.Christ.cit, 
#  formula = FGN.Christ.cit$DVcho ~ 
#    FGN.Christ.cit$Age + FGN.Christ.cit$AGE2 + FGN.Christ.cit$Woman + FGN.Christ.cit$Education + FGN.Christ.cit$cntry + 
#    FGN.Christ.cit$Politician.is.NonRel + FGN.Christ.cit$Politician.is.Christ,
#  cluster=FGN.Christ.cit$INTNR, 
#  weights=FGN.Christ.cit$w8eth)
#summary(FGN.Christ.cit.lm.cluster.refcatMuslim)
##tov Non-rel
#FGN.Christ.cit.lm.cluster.refcatNonRel <- miceadds::lm.cluster(
#  data=FGN.Christ.cit, 
#  formula = FGN.Christ.cit$DVcho ~ 
#    FGN.Christ.cit$Age + FGN.Christ.cit$AGE2 + FGN.Christ.cit$Woman + FGN.Christ.cit$Education + FGN.Christ.cit$cntry + 
#    FGN.Christ.cit$Politician.is.Muslim + FGN.Christ.cit$Politician.is.Christ,
#  cluster=FGN.Christ.cit$INTNR, 
#  weights=FGN.Christ.cit$w8eth)
#summary(FGN.Christ.cit.lm.cluster.refcatNonRel)

#Muslim
FGN.Muslim.cit <- subset(FGN, Citizen.Religion=="Muslim citizen")
#tov Mus
FGN.Muslim.cit.lm.cluster.refcatMus <- miceadds::lm.cluster(
  data=FGN.Muslim.cit, 
  formula = FGN.Muslim.cit$DVcho ~ 
    FGN.Muslim.cit$Age + FGN.Muslim.cit$AGE2 + FGN.Muslim.cit$Woman + FGN.Muslim.cit$Education + FGN.Muslim.cit$cntry + 
    FGN.Muslim.cit$Politician.is.NonRel + FGN.Muslim.cit$Politician.is.Christ,
  cluster=FGN.Muslim.cit$INTNR)
summary(FGN.Muslim.cit.lm.cluster.refcatMus)
#tov nonrel
FGN.Muslim.cit.lm.cluster.refcatNonRel <- miceadds::lm.cluster(
  data=FGN.Muslim.cit, 
  formula = FGN.Muslim.cit$DVcho ~ 
    FGN.Muslim.cit$Age + FGN.Muslim.cit$AGE2 + FGN.Muslim.cit$Woman + FGN.Muslim.cit$Education + FGN.Muslim.cit$cntry + 
    FGN.Muslim.cit$Politician.is.Christ + FGN.Muslim.cit$Politician.is.Muslim,
  cluster=FGN.Muslim.cit$INTNR)
summary(FGN.Muslim.cit.lm.cluster.refcatNonRel)
#tov christ
FGN.Muslim.cit.lm.cluster.refcatChrist <- miceadds::lm.cluster(
  data=FGN.Muslim.cit, 
  formula = FGN.Muslim.cit$DVcho ~ 
    FGN.Muslim.cit$Age + FGN.Muslim.cit$AGE2 + FGN.Muslim.cit$Woman + FGN.Muslim.cit$Education + FGN.Muslim.cit$cntry + 
    FGN.Muslim.cit$Politician.is.NonRel + FGN.Muslim.cit$Politician.is.Muslim,
  cluster=FGN.Muslim.cit$INTNR)
summary(FGN.Muslim.cit.lm.cluster.refcatChrist)

#as tibble
FGN.NonRel.cit.lm.cluster.refcatMuslim.tib <- as_tibble(summary(FGN.NonRel.cit.lm.cluster.refcatMuslim))
FGN.NonRel.cit.lm.cluster.refcatChrist.tib <- as_tibble(summary(FGN.NonRel.cit.lm.cluster.refcatChrist))
FGN.NonRel.cit.lm.cluster.refcatNonRel.tib <- as_tibble(summary(FGN.NonRel.cit.lm.cluster.refcatNonRel))
FGN.Muslim.cit.lm.cluster.refcatMus.tib <- as_tibble(summary(FGN.Muslim.cit.lm.cluster.refcatMus))
FGN.Muslim.cit.lm.cluster.refcatNonRel.tib <- as_tibble(summary(FGN.Muslim.cit.lm.cluster.refcatNonRel))
FGN.Muslim.cit.lm.cluster.refcatChrist.tib <- as_tibble(summary(FGN.Muslim.cit.lm.cluster.refcatChrist))

#removing intercept
FGN.NonRel.cit.lm.cluster.refcatMuslim.tib <- FGN.NonRel.cit.lm.cluster.refcatMuslim.tib[-(1:7),] #remove the intercept and control vars
FGN.NonRel.cit.lm.cluster.refcatChrist.tib <- FGN.NonRel.cit.lm.cluster.refcatChrist.tib[-(1:7), ] #remove the intercept and control vars
FGN.NonRel.cit.lm.cluster.refcatNonRel.tib <- FGN.NonRel.cit.lm.cluster.refcatNonRel.tib[-(1:7), ] #remove the intercept and control vars
FGN.Muslim.cit.lm.cluster.refcatMus.tib <- FGN.Muslim.cit.lm.cluster.refcatMus.tib[-(1:7), ] #remove the intercept and control vars
FGN.Muslim.cit.lm.cluster.refcatNonRel.tib <- FGN.Muslim.cit.lm.cluster.refcatNonRel.tib[-(1:7), ] #remove the intercept and control vars
FGN.Muslim.cit.lm.cluster.refcatChrist.tib <- FGN.Muslim.cit.lm.cluster.refcatChrist.tib[-(1:7), ] #remove the intercept and control vars

#lm.cluster.fig5.rbind
#Religion
lm.cluster.fig5.Religion.rbind <- rbind(FGN.NonRel.cit.lm.cluster.refcatMuslim.tib,
                                        FGN.NonRel.cit.lm.cluster.refcatChrist.tib,
                                        FGN.NonRel.cit.lm.cluster.refcatNonRel.tib,#
                                        FGN.Muslim.cit.lm.cluster.refcatMus.tib,#
                                        FGN.Muslim.cit.lm.cluster.refcatNonRel.tib,
                                        FGN.Muslim.cit.lm.cluster.refcatChrist.tib)

lm.cluster.fig5.Religion.df <- data.frame(
  names=c("Non-religious voter\nChristian politician\nrefcat Muslim politician", "Non-religious voter\nnon-religious politician\nrefcat Muslim politician",
          "Non-religious voter\n Muslim politician\nrefcat Christian politician", "Non-religious voter\nnon-religious politician\nrefcat Christian politician",
          "Non-religious voter\nMuslim politician\nrefcat non-religious politician", "Non-religious voter\nChristian politician\nrefcat non-religious politician",
          
          "Muslim voter\nNon-religious politician\nrefcat Muslim politician", "Muslim voter\nChristian politician\nrefcat Muslim politician",
          "Muslim voter\nChristian politician\nrefcat non-religious politician", "Muslim voter\nMuslim politician\nrefcat non-religious politician",
          "Muslim voter\nnon-religious politician\nrefcat Christian politician", "Muslim voter\nMuslim politician\nrefcat Christian politician"),
  estimate=lm.cluster.fig5.Religion.rbind$Estimate,
  conf.low=((lm.cluster.fig5.Religion.rbind$Estimate)-1.96*lm.cluster.fig5.Religion.rbind$`Std. Error`),
  conf.high=((lm.cluster.fig5.Religion.rbind$Estimate)+1.96*lm.cluster.fig5.Religion.rbind$`Std. Error`),
  number=c("001", "002", "003", "004"))

min(lm.cluster.fig5.Religion.df$conf.low)
max(lm.cluster.fig5.Religion.df$conf.high)

#ggplot
fig5.lm.cluster.fig5.Religion.df <- ggplot(data = lm.cluster.fig5.Religion.df, 
                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  ggtitle(" ") +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-0.1498017, 0.1498017) +
  geom_vline(xintercept = 0) + 
  theme(plot.title.position = "plot") 

library("patchwork")
fig7 <- fig5.lm.cluster.fig5.Religion.df + 
  plot_annotation(title = 'Linear model coefficients of voting likelihood per religion:',
                  #subtitle = ' ',
                  caption = "
                  Coefficients returned from four linear models, each with a different subset of voters (Muslim and non-religious) and each with a different
                  reference category (Muslim, non-religious or Christian politicians). I ranked coefficient estimates from highest to lowest. Clustered at
                  the level of the respondent. I ran separate models for each subset of voters and reference category and weighted the non-religious subset
                  by migration background while not doing so for the Muslim subset. Error bars represent the 95% confidence interval.")
fig7
#ggsave(fig7, width = 8, height = 8, file="ranking the haters and the lovers.jpeg")  

#--------------------------------#
#--- Histogram of PP on Islam ---#
#--------------------------------#

#islam.not.restricted
FGN$islam.not.restricted010 <- FGN$islam.not.restricted*10 
#FGN.NonRel.cit
FGN.NonRel.cit <- subset(FGN, Citizen.Religion=="non-religious citizen")
Hist1a.islam.not.restricted <- ggplot(FGN.NonRel.cit, aes(x = factor(islam.not.restricted010), 
                                                          weight = w8eth,
                                                          label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Amongst non-religious citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

#FGN.Muslim.cit
FGN.Muslim.cit <- subset(FGN, Citizen.Religion=="Muslim citizen")
Hist1b.islam.not.restricted <- ggplot(FGN.Muslim.cit, aes(x = factor(islam.not.restricted010), 
                                                          label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                            Fully agree") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Amongst Muslim citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

library("patchwork")
fig8 <- Hist1a.islam.not.restricted/Hist1b.islam.not.restricted + 
  plot_annotation(title = "Distribution of responses to statement:\n'Islam should not be restricted by law'",
                  #subtitle = ' ',
                  caption = "
                  I weighted the non-religious subset on migration background")
fig8
#ggsave(fig8, width = 6, height = 6, file="Histogram of pp on Islam.jpeg") 

#------------------------------------#
#--- Fig5 same gender PER COUNTRY ---#
#------------------------------------#

#France
FGN.France <- subset(FGN, cntry=="France")
FGN.France$PolCit.Gender <- 
  interaction(FGN.France$Citizen.Gender, FGN.France$Politician.Gender, sep = " + ")
PolCit.Gender.France <- mm(FGN.France, DVcho ~ PolCit.Gender,
                           id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Gender.France

PolCit.Gender.FranceDF <- data.frame(
  names=PolCit.Gender.France$level,
  estimate=PolCit.Gender.France$estimate*100,
  conf.low=PolCit.Gender.France$lower*100,
  conf.high=PolCit.Gender.France$upper*100,
  number=c("001", "004", "003", "002"))

PolCit.Gender.FranceDF

Fig5Gender.France <- ggplot(data = PolCit.Gender.FranceDF, 
                            aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("France") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Germany
FGN.Germany <- subset(FGN, cntry=="Germany")
FGN.Germany$PolCit.Gender <- 
  interaction(FGN.Germany$Citizen.Gender, FGN.Germany$Politician.Gender, sep = " + ")
PolCit.Gender.Germany <- mm(FGN.Germany, DVcho ~ PolCit.Gender,
                            id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Gender.Germany

PolCit.Gender.GermanyDF <- data.frame(
  names=PolCit.Gender.Germany$level,
  estimate=PolCit.Gender.Germany$estimate*100,
  conf.low=PolCit.Gender.Germany$lower*100,
  conf.high=PolCit.Gender.Germany$upper*100,
  number=c("001", "004", "003", "002"))

PolCit.Gender.GermanyDF

Fig5Gender.Germany <- ggplot(data = PolCit.Gender.GermanyDF, 
                             aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Germany") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Netherlands
FGN.Netherlands <- subset(FGN, cntry=="Netherlands")
FGN.Netherlands$PolCit.Gender <- 
  interaction(FGN.Netherlands$Citizen.Gender, FGN.Netherlands$Politician.Gender, sep = " + ")
PolCit.Gender.Netherlands <- mm(FGN.Netherlands, DVcho ~ PolCit.Gender,
                                id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Gender.Netherlands

PolCit.Gender.NetherlandsDF <- data.frame(
  names=PolCit.Gender.Netherlands$level,
  estimate=PolCit.Gender.Netherlands$estimate*100,
  conf.low=PolCit.Gender.Netherlands$lower*100,
  conf.high=PolCit.Gender.Netherlands$upper*100,
  number=c("001", "004", "003", "002"))

PolCit.Gender.NetherlandsDF

Fig5Gender.Netherlands <- ggplot(data = PolCit.Gender.NetherlandsDF, 
                                 aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Netherlands") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

library("patchwork")
Fig5 <- Fig5Gender.France/Fig5Gender.Germany/Fig5Gender.Netherlands +
  plot_annotation(title = 'Voting likelihood when voter and politician share the same gender:',
                  subtitle = ' ',
                  caption = "
Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they were most likely to vote for. 
                  Error bars represent the 95% confidence interval. Weighted on migration background.") 
Fig5 
##ggsave(Fig5, width = 8, height = 4, file="Fig5 no gender affinity effect.jpeg") 

#-------------------------------------#
#--- linear models of all together ---#
#-------------------------------------#

#Religion
#NonRel
FGN.NonRel.cit <- subset(FGN, Citizen.Religion=="non-religious citizen")
#tov Moslim
FGN.NonRel.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.NonRel.cit, 
  formula = FGN.NonRel.cit$DVcho ~ 
    FGN.NonRel.cit$Age + FGN.NonRel.cit$AGE2 + FGN.NonRel.cit$Woman + FGN.NonRel.cit$Education + FGN.NonRel.cit$cntry +
    FGN.NonRel.cit$Politician.is.Christ + FGN.NonRel.cit$Politician.is.NonRel,
  cluster=FGN.NonRel.cit$INTNR, 
  weights=FGN.NonRel.cit$w8eth)
summary(FGN.NonRel.cit.lm.cluster)
#tov Christian
FGN.NonRel.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.NonRel.cit, 
  formula = FGN.NonRel.cit$DVcho ~ 
    FGN.NonRel.cit$Age + FGN.NonRel.cit$AGE2 + FGN.NonRel.cit$Woman + FGN.NonRel.cit$Education + FGN.NonRel.cit$cntry +
    FGN.NonRel.cit$Politician.is.Muslim + FGN.NonRel.cit$Politician.is.NonRel,
  cluster=FGN.NonRel.cit$INTNR, 
  weights=FGN.NonRel.cit$w8eth)
summary(FGN.NonRel.cit.lm.cluster)

#Christ
FGN.Christ.cit <- subset(FGN, Citizen.Religion=="Christian citizen")
#tov Moslim
FGN.Christ.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.Christ.cit, 
  formula = FGN.Christ.cit$DVcho ~ 
    FGN.Christ.cit$Age + FGN.Christ.cit$AGE2 + FGN.Christ.cit$Woman + FGN.Christ.cit$Education + FGN.Christ.cit$cntry + 
    FGN.Christ.cit$Politician.is.NonRel + FGN.Christ.cit$Politician.is.Christ,
  cluster=FGN.Christ.cit$INTNR, 
  weights=FGN.Christ.cit$w8eth)
summary(FGN.Christ.cit.lm.cluster)
#tov Non-rel
FGN.Christ.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.Christ.cit, 
  formula = FGN.Christ.cit$DVcho ~ 
    FGN.Christ.cit$Age + FGN.Christ.cit$AGE2 + FGN.Christ.cit$Woman + FGN.Christ.cit$Education + FGN.Christ.cit$cntry + 
    FGN.Christ.cit$Politician.is.Muslim + FGN.Christ.cit$Politician.is.Christ,
  cluster=FGN.Christ.cit$INTNR, 
  weights=FGN.Christ.cit$w8eth)
summary(FGN.Christ.cit.lm.cluster)

#Muslim
FGN.Muslim.cit <- subset(FGN, Citizen.Religion=="Muslim citizen")
#tov nonrel
FGN.Muslim.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.Muslim.cit, 
  formula = FGN.Muslim.cit$DVcho ~ 
    FGN.Muslim.cit$Age + FGN.Muslim.cit$AGE2 + FGN.Muslim.cit$Woman + FGN.Muslim.cit$Education + FGN.Muslim.cit$cntry + 
    FGN.Muslim.cit$Politician.is.Christ + FGN.Muslim.cit$Politician.is.Muslim,
  cluster=FGN.Muslim.cit$INTNR)
summary(FGN.Muslim.cit.lm.cluster)
#tov christ
FGN.Muslim.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.Muslim.cit, 
  formula = FGN.Muslim.cit$DVcho ~ 
    FGN.Muslim.cit$Age + FGN.Muslim.cit$AGE2 + FGN.Muslim.cit$Woman + FGN.Muslim.cit$Education + FGN.Muslim.cit$cntry + 
    FGN.Muslim.cit$Politician.is.NonRel + FGN.Muslim.cit$Politician.is.Muslim,
  cluster=FGN.Muslim.cit$INTNR)
summary(FGN.Muslim.cit.lm.cluster)

#migration background
#NoMig
FGN.NoMig.cit <- subset(FGN, Citizen.Ethnorace=="Citizen without migration background")
FGN.NoMig.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.NoMig.cit, 
  formula = FGN.NoMig.cit$DVcho ~ 
    FGN.NoMig.cit$Age + FGN.NoMig.cit$AGE2 + FGN.NoMig.cit$Woman + FGN.NoMig.cit$Education + FGN.NoMig.cit$cntry + 
    FGN.NoMig.cit$Politician.frm.Tur + FGN.NoMig.cit$Politician.frm.Mag + FGN.NoMig.cit$Politician.frm.SSA + FGN.NoMig.cit$Politician.frm.FSU + FGN.NoMig.cit$Politician.frm.Mor + FGN.NoMig.cit$Politician.frm.Sur,
  cluster=FGN.NoMig.cit$INTNR)
summary(FGN.NoMig.cit.lm.cluster)

#NoMig
FGN.NoMig.cit <- subset(FGN, Citizen.Ethnorace=="Citizen without migration background")
FGN.NoMig.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.NoMig.cit, 
  formula = FGN.NoMig.cit$DVcho ~ 
    FGN.NoMig.cit$Age + FGN.NoMig.cit$AGE2 + FGN.NoMig.cit$Woman + FGN.NoMig.cit$Education + FGN.NoMig.cit$cntry + 
    FGN.NoMig.cit$Politician.frm.FGN,
  cluster=FGN.NoMig.cit$INTNR)
summary(FGN.NoMig.cit.lm.cluster)

#Tur
FGN.Tur.cit <- subset(FGN, Citizen.Ethnorace=="Turkish citizen")
FGN.Tur.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.Tur.cit, 
  formula = FGN.Tur.cit$DVcho ~ 
    #FGN$Age + FGN$AGE2 + FGN$Woman + 
    FGN.Tur.cit$Politician.frm.Tur + FGN.Tur.cit$Politician.frm.Mag + FGN.Tur.cit$Politician.frm.SSA + FGN.Tur.cit$Politician.frm.FSU + FGN.Tur.cit$Politician.frm.Mor + FGN.Tur.cit$Politician.frm.Sur,
  cluster=FGN.Tur.cit$INTNR)
summary(FGN.Tur.cit.lm.cluster)

#Mag
FGN.Mag.cit <- subset(FGN, Citizen.Ethnorace=="North-African citizen (France)")
FGN.Mag.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.Mag.cit, 
  formula = FGN.Mag.cit$DVcho ~ 
    #FGN$Age + FGN$AGE2 + FGN$Woman + 
    FGN.Mag.cit$Politician.frm.Tur + FGN.Mag.cit$Politician.frm.Mag + FGN.Mag.cit$Politician.frm.SSA + FGN.Mag.cit$Politician.frm.FSU + FGN.Mag.cit$Politician.frm.Mor + FGN.Mag.cit$Politician.frm.Sur,
  cluster=FGN.Mag.cit$INTNR)
summary(FGN.Mag.cit.lm.cluster)

#SSA
FGN.SSA.cit <- subset(FGN, Citizen.Ethnorace=="Sub-Saharan African citizen (France)")
FGN.SSA.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.SSA.cit, 
  formula = FGN.SSA.cit$DVcho ~ 
    #FGN$Age + FGN$AGE2 + FGN$Woman + 
    FGN.SSA.cit$Politician.frm.Tur + FGN.SSA.cit$Politician.frm.Mag + FGN.SSA.cit$Politician.frm.SSA + FGN.SSA.cit$Politician.frm.FSU + FGN.SSA.cit$Politician.frm.Mor + FGN.SSA.cit$Politician.frm.Sur,
  cluster=FGN.SSA.cit$INTNR)
summary(FGN.SSA.cit.lm.cluster)

#FSU
FGN.FSU.cit <- subset(FGN, Citizen.Ethnorace=="FSU citizen (Germany)")
FGN.FSU.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.FSU.cit, 
  formula = FGN.FSU.cit$DVcho ~ 
    #FGN$Age + FGN$AGE2 + FGN$Woman + 
    FGN.FSU.cit$Politician.frm.Tur + FGN.FSU.cit$Politician.frm.Mag + FGN.FSU.cit$Politician.frm.SSA + FGN.FSU.cit$Politician.frm.FSU + FGN.FSU.cit$Politician.frm.Mor + FGN.FSU.cit$Politician.frm.Sur,
  cluster=FGN.FSU.cit$INTNR)
summary(FGN.FSU.cit.lm.cluster)

#Mor
FGN.Mor.cit <- subset(FGN, Citizen.Ethnorace=="Moroccan citizen (Netherlands)")
FGN.Mor.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.Mor.cit, 
  formula = FGN.Mor.cit$DVcho ~ 
    #FGN$Age + FGN$AGE2 + FGN$Woman + 
    FGN.Mor.cit$Politician.frm.Tur + FGN.Mor.cit$Politician.frm.Mag + FGN.Mor.cit$Politician.frm.SSA + FGN.Mor.cit$Politician.frm.FSU + FGN.Mor.cit$Politician.frm.Mor + FGN.Mor.cit$Politician.frm.Sur,
  cluster=FGN.Mor.cit$INTNR)
summary(FGN.Mor.cit.lm.cluster)

#Sur
FGN.Sur.cit <- subset(FGN, Citizen.Ethnorace=="Surinamese citizen (Netherlands)")
FGN.Sur.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.Sur.cit, 
  formula = FGN.Sur.cit$DVcho ~ 
    #FGN$Age + FGN$AGE2 + FGN$Woman + 
    FGN.Sur.cit$Politician.frm.Tur + FGN.Sur.cit$Politician.frm.Mag + FGN.Sur.cit$Politician.frm.SSA + FGN.Sur.cit$Politician.frm.FSU + FGN.Sur.cit$Politician.frm.Mor + FGN.Sur.cit$Politician.frm.Sur,
  cluster=FGN.Sur.cit$INTNR)
summary(FGN.Sur.cit.lm.cluster)

#gender
#Mal
FGN.mal.cit <- subset(FGN, Citizen.Gender=="Male citizen")
FGN.mal.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.mal.cit, 
  formula = FGN.mal.cit$DVcho ~ 
    #FGN$Age + FGN$AGE2 + FGN$Woman + 
    FGN.mal.cit$Politician.is.Woman,
  cluster=FGN.mal.cit$INTNR, 
  weights=FGN.mal.cit$w8eth)
summary(FGN.mal.cit.lm.cluster)

#Fem
FGN.fem.cit <- subset(FGN, Citizen.Gender=="Female citizen")
FGN.fem.cit.lm.cluster <- miceadds::lm.cluster(
  data=FGN.fem.cit, 
  formula = FGN.fem.cit$DVcho ~ 
    #FGN$Age + FGN$AGE2 + FGN$Woman + 
    FGN.fem.cit$Politician.is.Woman,
  cluster=FGN.fem.cit$INTNR, 
  weights=FGN.fem.cit$w8eth)
summary(FGN.fem.cit.lm.cluster)

#as tibble
FGN.NonRel.cit.lm.cluster.tib <- as_tibble(summary(FGN.NonRel.cit.lm.cluster))
FGN.Christ.cit.lm.cluster.tib <- as_tibble(summary(FGN.Christ.cit.lm.cluster))
FGN.Muslim.cit.lm.cluster.tib <- as_tibble(summary(FGN.Muslim.cit.lm.cluster))
FGN.NoMig.cit.lm.cluster.tib <- as_tibble(summary(FGN.NoMig.cit.lm.cluster))
FGN.Tur.cit.lm.cluster.tib <- as_tibble(summary(FGN.Tur.cit.lm.cluster))
FGN.Mag.cit.lm.cluster.tib <- as_tibble(summary(FGN.Mag.cit.lm.cluster))
FGN.SSA.cit.lm.cluster.tib <- as_tibble(summary(FGN.SSA.cit.lm.cluster))
FGN.FSU.cit.lm.cluster.tib <- as_tibble(summary(FGN.FSU.cit.lm.cluster))
FGN.Mor.cit.lm.cluster.tib <- as_tibble(summary(FGN.Mor.cit.lm.cluster))
FGN.Sur.cit.lm.cluster.tib <- as_tibble(summary(FGN.Sur.cit.lm.cluster))
FGN.mal.cit.lm.cluster.tib <- as_tibble(summary(FGN.mal.cit.lm.cluster))
FGN.fem.cit.lm.cluster.tib <- as_tibble(summary(FGN.fem.cit.lm.cluster))

#removing intercept
FGN.NonRel.cit.lm.cluster.tib <- FGN.NonRel.cit.lm.cluster.tib[-1, ] #remove the intercept
FGN.Christ.cit.lm.cluster.tib <- FGN.Christ.cit.lm.cluster.tib[-1, ] #remove the intercept
FGN.Muslim.cit.lm.cluster.tib <- FGN.Muslim.cit.lm.cluster.tib[-1, ] #remove the intercept
FGN.NoMig.cit.lm.cluster.tib <- FGN.NoMig.cit.lm.cluster.tib[-1, ] #remove the intercept
FGN.Tur.cit.lm.cluster.tib <- FGN.Tur.cit.lm.cluster.tib[-1, ] #remove the intercept
FGN.Mag.cit.lm.cluster.tib <- FGN.Mag.cit.lm.cluster.tib[-1, ] #remove the intercept
FGN.SSA.cit.lm.cluster.tib <- FGN.SSA.cit.lm.cluster.tib[-1, ] #remove the intercept
FGN.FSU.cit.lm.cluster.tib <- FGN.FSU.cit.lm.cluster.tib[-1, ] #remove the intercept
FGN.Mor.cit.lm.cluster.tib <- FGN.Mor.cit.lm.cluster.tib[-1, ] #remove the intercept
FGN.Sur.cit.lm.cluster.tib <- FGN.Sur.cit.lm.cluster.tib[-1, ] #remove the intercept
FGN.mal.cit.lm.cluster.tib <- FGN.mal.cit.lm.cluster.tib[-1, ] #remove the intercept
FGN.fem.cit.lm.cluster.tib <- FGN.fem.cit.lm.cluster.tib[-1, ] #remove the intercept

#lm.cluster.fig5.rbind
#Religion
lm.cluster.fig5.Religion.rbind <- rbind(FGN.NonRel.cit.lm.cluster.tib,
                                        FGN.Christ.cit.lm.cluster.tib,
                                        FGN.Muslim.cit.lm.cluster.tib)

lm.cluster.fig5.Religion.df <- data.frame(
  names=c("Non-religious voter, Muslim politician", "Non-religious voter, Christian politician", 
          "Christian voter, Muslim politician", "Christian voter, Christian politician", 
          "Muslim voter, Muslim politician", "Muslim voter, Christian politician"),
  estimate=lm.cluster.fig5.Religion.rbind$Estimate,
  conf.low=((lm.cluster.fig5.Religion.rbind$Estimate)-1.96*lm.cluster.fig5.Religion.rbind$`Std. Error`),
  conf.high=((lm.cluster.fig5.Religion.rbind$Estimate)+1.96*lm.cluster.fig5.Religion.rbind$`Std. Error`),
  number=c("001", "002", "003", "004", "005", "006"))

#ggplot
hline1.fig5.lm.cluster.fig5.Religion.df <- data.frame(z = c(0.5,
                                                            2.5,
                                                            28.5,
                                                            34.5)) 
hline2.fig5.lm.cluster.fig5.Religion.df <- data.frame(z = c(1.5,
                                                            5.5,
                                                            8.5,
                                                            10.5,
                                                            13.5,
                                                            16.5,
                                                            22.5,
                                                            30.5,
                                                            32.5)) 

fig5.lm.cluster.fig5.Religion.df <- ggplot(data = lm.cluster.fig5.Religion.df, 
                                           aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  ggtitle("Religion") +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-0.1880305, 0.2288725) +
  geom_vline(xintercept = 0) + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dashed", 
             aes(yintercept = z), 
             hline1.fig5.lm.cluster.fig5.Religion.df) +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline2.fig5.lm.cluster.fig5.Religion.df)
fig5.lm.cluster.fig5.Religion.df

#Migration background
lm.cluster.fig5.Migrationbackground.rbind <- rbind(FGN.NoMig.cit.lm.cluster.tib,
                                                   FGN.Tur.cit.lm.cluster.tib,
                                                   FGN.Mag.cit.lm.cluster.tib,
                                                   FGN.SSA.cit.lm.cluster.tib,
                                                   FGN.FSU.cit.lm.cluster.tib,
                                                   FGN.Mor.cit.lm.cluster.tib,
                                                   FGN.Sur.cit.lm.cluster.tib)

lm.cluster.fig5.Migrationbackground.df <- data.frame(
  names=c("Voter without migration background, Turkish politician (France, Germany, Netherlands)", "Voter without migration background, Maghrebi politician (France)", "Voter without migration background, Sub-Saharan African politician (France)", "Voter without migration background, FSU politician (Germany)", "Voter without migration background, Moroccan politician (Netherlands)", "Voter without migration background, Surinamese politician (Netherlands)",    
          "Voter with background in Turkey, Turkish politician (France, Germany, Netherlands)", "Voter with background in Turkey, Maghrebi politician (France)", "Voter with background in Turkey, Sub-Saharan African politician (France)", "Voter with background in Turkey, FSU politician (Germany)", "Voter with background in Turkey, Moroccan politician (Netherlands)", "Voter with background in Turkey, Surinamese politician (Netherlands)",    
          "Voter with background in Maghreb (France), Turkish politician (France)", "Voter with background in Maghreb (France), Maghrebi politician (France)", "Voter with background in Maghreb (France), Sub-Saharan African politician (France)", 
          "Voter with background in Sub-Saharan Africa (France), Turkish politician (France)", "Voter with background in Sub-Saharan Africa (France), Maghrebi politician (France)", "Voter with background in Sub-Saharan Africa (France), Sub-Saharan African politician (France)", 
          "Voter with background in FSU (Germany), Turkish politician (Germany)", "Voter with background in FSU (Germany), FSU politician (Germany)", 
          "Voter with background in Morocco (Netherlands), Turkish politician (Netherlands)", "Voter with background in Morocco (Netherlands), Moroccan politician (Netherlands)", "Voter with background in Morocco (Netherlands), Surinamese politician (Netherlands)",  
          "Voter with background in Surinam (Netherlands), Turkish politician (Netherlands)", "Voter with background in Surinam (Netherlands), Moroccan politician (Netherlands)", "Voter with background in Surinam (Netherlands), Surinamese politician (Netherlands)"),
  estimate=lm.cluster.fig5.Migrationbackground.rbind$Estimate,
  conf.low=((lm.cluster.fig5.Migrationbackground.rbind$Estimate)-1.96*lm.cluster.fig5.Migrationbackground.rbind$`Std. Error`),
  conf.high=((lm.cluster.fig5.Migrationbackground.rbind$Estimate)+1.96*lm.cluster.fig5.Migrationbackground.rbind$`Std. Error`),
  number=c("001", "002", "003", "004", "005", "006", "007", "008", "009", "010",
           "011", "012", "013", "014", "015", "016", "017", "018", "019", "020",
           "021", "022", "023", "024", "025", "026"))

#ggplot
hline1.fig5.lm.cluster.fig5.Migrationbackground.df <- data.frame(z = c(0.5,
                                                                       2.5,
                                                                       28.5,
                                                                       34.5)) 
hline2.fig5.lm.cluster.fig5.Migrationbackground.df <- data.frame(z = c(1.5,
                                                                       5.5,
                                                                       8.5,
                                                                       10.5,
                                                                       13.5,
                                                                       16.5,
                                                                       22.5,
                                                                       30.5,
                                                                       32.5)) 

fig5.lm.cluster.fig5.Migrationbackground.df <- ggplot(data = lm.cluster.fig5.Migrationbackground.df, 
                                                      aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  ggtitle("Migration background") +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-0.1880305, 0.2288725) +
  geom_vline(xintercept = 0) + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dashed", 
             aes(yintercept = z), 
             hline1.fig5.lm.cluster.fig5.Migrationbackground.df) +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline2.fig5.lm.cluster.fig5.Migrationbackground.df)
fig5.lm.cluster.fig5.Migrationbackground.df

#Gender
lm.cluster.fig5.Gender.rbind <- rbind(FGN.mal.cit.lm.cluster.tib,
                                      FGN.fem.cit.lm.cluster.tib)

lm.cluster.fig5.Gender.df <- data.frame(
  names=c("Male voter, female politician", "Female voter, female politician"),
  estimate=lm.cluster.fig5.Gender.rbind$Estimate,
  conf.low=((lm.cluster.fig5.Gender.rbind$Estimate)-1.96*lm.cluster.fig5.Gender.rbind$`Std. Error`),
  conf.high=((lm.cluster.fig5.Gender.rbind$Estimate)+1.96*lm.cluster.fig5.Gender.rbind$`Std. Error`),
  number=c("001", "002"))

#ggplot
hline1.fig5.lm.cluster.fig5.Gender.df <- data.frame(z = c(0.5,
                                                          2.5,
                                                          28.5,
                                                          34.5)) 
hline2.fig5.lm.cluster.fig5.Gender.df <- data.frame(z = c(1.5,
                                                          5.5,
                                                          8.5,
                                                          10.5,
                                                          13.5,
                                                          16.5,
                                                          22.5,
                                                          30.5,
                                                          32.5)) 

fig5.lm.cluster.fig5.Gender.df <- ggplot(data = lm.cluster.fig5.Gender.df, 
                                         aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  ggtitle("Gender") +
  theme_minimal() +
  ylab(" ") + 
  xlab("Linear model coefficients") + 
  xlim(-0.1880305, 0.2288725) +
  geom_vline(xintercept = 0) + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dashed", 
             aes(yintercept = z), 
             hline1.fig5.lm.cluster.fig5.Gender.df) +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline2.fig5.lm.cluster.fig5.Gender.df)
fig5.lm.cluster.fig5.Gender.df

library("patchwork")
Fig5 <- fig5.lm.cluster.fig5.Religion.df/fig5.lm.cluster.fig5.Migrationbackground.df/fig5.lm.cluster.fig5.Gender.df + 
  plot_annotation(title = 'Linear model coefficients of voting likelihood when voter and politician share the same:',
                  subtitle = ' ',
                  caption = "
                  Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they were most likely to vote for. I ran separate
                  models for each subset of voters. Reference categories are non-religious politicians, politicians without a migration background and male
                  politicians. Error bars represent the 95% confidence interval. Weighted on migration background (except not for the analyses subsetted on
                  voter migration background), gender, education, region and urbanization.") + 
  plot_layout(heights = c(6, 26, 2))
Fig5
#ggsave(Fig5, width = 8, height = 12, file="Fig5.jpeg") 

#-----------------------#
#--- fig1.percountry ---#
#-----------------------#

#France
FGN.France <- subset(FGN, cntry=="France")

#Policy.Position.samepp H4
PolCit.France.samepp <- mm(FGN.France, DVcho ~ samepp,
                           id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.France.sameppDF <- data.frame(
  names=PolCit.France.samepp$level,
  estimate=PolCit.France.samepp$estimate*100,
  conf.low=PolCit.France.samepp$lower*100,
  conf.high=PolCit.France.samepp$upper*100,
  number=c("002", "001"))
fig1.FrancePolicy.Position.samepp <- ggplot(data = PolCit.France.sameppDF, 
                                            aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...policy position?") + 
  theme(plot.title.position = "plot")
#fig1.FrancePolicy.Position.samepp

#Religion H2b
PolCit.France.samerel <- mm(FGN.France, DVcho ~ samerel,
                            id = ~ INTNR, h0 = 0.5)
PolCit.France.ReligionDF <- data.frame(
  names=PolCit.France.samerel$level,
  estimate=PolCit.France.samerel$estimate*100,
  conf.low=PolCit.France.samerel$lower*100,
  conf.high=PolCit.France.samerel$upper*100,
  number=c("001", "002"))
fig1.Francereligion <- ggplot(data = PolCit.France.ReligionDF, 
                              aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...religion?") + 
  theme(plot.title.position = "plot")
#fig1.Francereligion

#Ethnorace H2a
PolCit.France.sameeth <- mm(FGN.France, DVcho ~ sameeth,
                            id = ~ INTNR, h0 = 0.5)
PolCit.France.EthnoraceDF <- data.frame(
  names=PolCit.France.sameeth$level,
  estimate=PolCit.France.sameeth$estimate*100,
  conf.low=PolCit.France.sameeth$lower*100,
  conf.high=PolCit.France.sameeth$upper*100,
  number=c("001", "002"))
fig1.FranceEthnorace <- ggplot(data = PolCit.France.EthnoraceDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...migration background?") + 
  theme(plot.title.position = "plot")
#fig1.FranceEthnorace

#Gender H2c
PolCit.France.samegen <- mm(FGN.France, DVcho ~ samegen,
                            id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.France.GenderDF <- data.frame(
  names=PolCit.France.samegen$level,
  estimate=PolCit.France.samegen$estimate*100,
  conf.low=PolCit.France.samegen$lower*100,
  conf.high=PolCit.France.samegen$upper*100,
  number=c("001", "002"))
fig1.FranceGender <- ggplot(data = PolCit.France.GenderDF, 
                            aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...gender?") + 
  theme(plot.title.position = "plot")
#fig1.FranceGender

library("patchwork")
fig1.France <- fig1.FrancePolicy.Position.samepp/fig1.Francereligion/fig1.FranceEthnorace/fig1.FranceGender +
  plot_annotation(title = 'France:\nDoes it matter whether citizen and politician share the same...',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Same policy position and gender were weighted on
                  migration background, gender, education, region and urbanization. Same religion and ethnorace were 
                  weighted on gender, education, region and urbanization.") 
fig1.France 
#ggsave(fig1.France, width = 7, height = 10, file="fig1.France.jpeg")  

#Germany
FGN.Germany <- subset(FGN, cntry=="Germany")

#Policy.Position.samepp H4
PolCit.Germany.samepp <- mm(FGN.Germany, DVcho ~ samepp,
                            id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Germany.sameppDF <- data.frame(
  names=PolCit.Germany.samepp$level,
  estimate=PolCit.Germany.samepp$estimate*100,
  conf.low=PolCit.Germany.samepp$lower*100,
  conf.high=PolCit.Germany.samepp$upper*100,
  number=c("002", "001"))
fig1.GermanyPolicy.Position.samepp <- ggplot(data = PolCit.Germany.sameppDF, 
                                             aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...policy position?") + 
  theme(plot.title.position = "plot")
#fig1.GermanyPolicy.Position.samepp

#Religion H2b
PolCit.Germany.samerel <- mm(FGN.Germany, DVcho ~ samerel,
                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Germany.ReligionDF <- data.frame(
  names=PolCit.Germany.samerel$level,
  estimate=PolCit.Germany.samerel$estimate*100,
  conf.low=PolCit.Germany.samerel$lower*100,
  conf.high=PolCit.Germany.samerel$upper*100,
  number=c("001", "002"))
fig1.Germanyreligion <- ggplot(data = PolCit.Germany.ReligionDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...religion?") + 
  theme(plot.title.position = "plot")
#fig1.Germanyreligion

#Ethnorace H2a
PolCit.Germany.sameeth <- mm(FGN.Germany, DVcho ~ sameeth,
                             id = ~ INTNR, h0 = 0.5)
PolCit.Germany.EthnoraceDF <- data.frame(
  names=PolCit.Germany.sameeth$level,
  estimate=PolCit.Germany.sameeth$estimate*100,
  conf.low=PolCit.Germany.sameeth$lower*100,
  conf.high=PolCit.Germany.sameeth$upper*100,
  number=c("001", "002"))
fig1.GermanyEthnorace <- ggplot(data = PolCit.Germany.EthnoraceDF, 
                                aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...migration background?") + 
  theme(plot.title.position = "plot")
#fig1.GermanyEthnorace

#Gender H2c
PolCit.Germany.samegen <- mm(FGN.Germany, DVcho ~ samegen,
                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Germany.GenderDF <- data.frame(
  names=PolCit.Germany.samegen$level,
  estimate=PolCit.Germany.samegen$estimate*100,
  conf.low=PolCit.Germany.samegen$lower*100,
  conf.high=PolCit.Germany.samegen$upper*100,
  number=c("001", "002"))
fig1.GermanyGender <- ggplot(data = PolCit.Germany.GenderDF, 
                             aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...gender?") + 
  theme(plot.title.position = "plot")
#fig1.GermanyGender

library("patchwork")
fig1.Germany <- fig1.GermanyPolicy.Position.samepp/fig1.Germanyreligion/fig1.GermanyEthnorace/fig1.GermanyGender +
  plot_annotation(title = 'Germany:\nDoes it matter whether citizen and politician share the same...',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Same policy position and gender were weighted on
                  migration background, gender, education, region and urbanization. Same religion and ethnorace were 
                  weighted on gender, education, region and urbanization.") 
fig1.Germany 
#ggsave(fig1.Germany, width = 7, height = 10, file="fig1.Germany.jpeg")  

#Netherlands
FGN.Netherlands <- subset(FGN, cntry=="Netherlands")

#Policy.Position.samepp H4
PolCit.Netherlands.samepp <- mm(FGN.Netherlands, DVcho ~ samepp,
                                id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Netherlands.sameppDF <- data.frame(
  names=PolCit.Netherlands.samepp$level,
  estimate=PolCit.Netherlands.samepp$estimate*100,
  conf.low=PolCit.Netherlands.samepp$lower*100,
  conf.high=PolCit.Netherlands.samepp$upper*100,
  number=c("002", "001"))
fig1.NetherlandsPolicy.Position.samepp <- ggplot(data = PolCit.Netherlands.sameppDF, 
                                                 aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...policy position?") + 
  theme(plot.title.position = "plot")
#fig1.NetherlandsPolicy.Position.samepp

#Religion H2b
PolCit.Netherlands.samerel <- mm(FGN.Netherlands, DVcho ~ samerel,
                                 id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Netherlands.ReligionDF <- data.frame(
  names=PolCit.Netherlands.samerel$level,
  estimate=PolCit.Netherlands.samerel$estimate*100,
  conf.low=PolCit.Netherlands.samerel$lower*100,
  conf.high=PolCit.Netherlands.samerel$upper*100,
  number=c("001", "002"))
fig1.Netherlandsreligion <- ggplot(data = PolCit.Netherlands.ReligionDF, 
                                   aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...religion?") + 
  theme(plot.title.position = "plot")
#fig1.Netherlandsreligion

#Ethnorace H2a
PolCit.Netherlands.sameeth <- mm(FGN.Netherlands, DVcho ~ sameeth,
                                 id = ~ INTNR, h0 = 0.5)
PolCit.Netherlands.EthnoraceDF <- data.frame(
  names=PolCit.Netherlands.sameeth$level,
  estimate=PolCit.Netherlands.sameeth$estimate*100,
  conf.low=PolCit.Netherlands.sameeth$lower*100,
  conf.high=PolCit.Netherlands.sameeth$upper*100,
  number=c("001", "002"))
fig1.NetherlandsEthnorace <- ggplot(data = PolCit.Netherlands.EthnoraceDF, 
                                    aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...migration background?") + 
  theme(plot.title.position = "plot")
#fig1.NetherlandsEthnorace

#Gender H2c
PolCit.Netherlands.samegen <- mm(FGN.Netherlands, DVcho ~ samegen,
                                 id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Netherlands.GenderDF <- data.frame(
  names=PolCit.Netherlands.samegen$level,
  estimate=PolCit.Netherlands.samegen$estimate*100,
  conf.low=PolCit.Netherlands.samegen$lower*100,
  conf.high=PolCit.Netherlands.samegen$upper*100,
  number=c("001", "002"))
fig1.NetherlandsGender <- ggplot(data = PolCit.Netherlands.GenderDF, 
                                 aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...gender?") + 
  theme(plot.title.position = "plot")
#fig1.NetherlandsGender

library("patchwork")
fig1.Netherlands <- fig1.NetherlandsPolicy.Position.samepp/fig1.Netherlandsreligion/fig1.NetherlandsEthnorace/fig1.NetherlandsGender +
  plot_annotation(title = 'Netherlands:\nDoes it matter whether citizen and politician share the same...',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Same policy position and gender were weighted on
                  migration background, gender, education, region and urbanization. Same religion and ethnorace were 
                  weighted on gender, education, region and urbanization.") 
fig1.Netherlands 
#ggsave(fig1.Netherlands, width = 7, height = 10, file="fig1.Netherlands.jpeg")  

#--------------------------------------#
#--- fig2 WHEN same policy position ---#
#--------------------------------------#

#France
#policy positions
#tax.rich.higher
PolCit.Policy.Position.tax.rich.higher <- mm(FGN.France, DVcho ~ samepp.tax.rich.higher,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.tax.rich.higherDF <- data.frame(
  names=PolCit.Policy.Position.tax.rich.higher$level,
  estimate=PolCit.Policy.Position.tax.rich.higher$estimate*100,
  conf.low=PolCit.Policy.Position.tax.rich.higher$lower*100,
  conf.high=PolCit.Policy.Position.tax.rich.higher$upper*100,
  number=c("003", "001", "002", "004"))
#raise.supp.unemp
PolCit.Policy.Position.raise.supp.unemp <- mm(FGN.France, DVcho ~ samepp.raise.supp.unemp,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.raise.supp.unempDF <- data.frame(
  names=PolCit.Policy.Position.raise.supp.unemp$level,
  estimate=PolCit.Policy.Position.raise.supp.unemp$estimate*100,
  conf.low=PolCit.Policy.Position.raise.supp.unemp$lower*100,
  conf.high=PolCit.Policy.Position.raise.supp.unemp$upper*100,
  number=c("003", "001", "002", "004"))
#more.com.climcha
PolCit.Policy.Position.more.com.climcha <- mm(FGN.France, DVcho ~ samepp.more.com.climcha,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.more.com.climchaDF <- data.frame(
  names=PolCit.Policy.Position.more.com.climcha$level,
  estimate=PolCit.Policy.Position.more.com.climcha$estimate*100,
  conf.low=PolCit.Policy.Position.more.com.climcha$lower*100,
  conf.high=PolCit.Policy.Position.more.com.climcha$upper*100,
  number=c("003", "001", "002", "004"))
#raise.fuel.price
PolCit.Policy.Position.raise.fuel.price <- mm(FGN.France, DVcho ~ samepp.raise.fuel.price,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.raise.fuel.priceDF <- data.frame(
  names=PolCit.Policy.Position.raise.fuel.price$level,
  estimate=PolCit.Policy.Position.raise.fuel.price$estimate*100,
  conf.low=PolCit.Policy.Position.raise.fuel.price$lower*100,
  conf.high=PolCit.Policy.Position.raise.fuel.price$upper*100,
  number=c("003", "001", "002", "004"))
#immigrants.R.asset
PolCit.Policy.Position.immigrants.R.asset <- mm(FGN.France, DVcho ~ samepp.immigrants.R.asset,
                                                id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.immigrants.R.assetDF <- data.frame(
  names=PolCit.Policy.Position.immigrants.R.asset$level,
  estimate=PolCit.Policy.Position.immigrants.R.asset$estimate*100,
  conf.low=PolCit.Policy.Position.immigrants.R.asset$lower*100,
  conf.high=PolCit.Policy.Position.immigrants.R.asset$upper*100,
  number=c("003", "001", "002", "004"))
#islam.not.restricted
PolCit.Policy.Position.islam.not.restricted <- mm(FGN.France, DVcho ~ samepp.islam.not.restricted,
                                                  id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.islam.not.restrictedDF <- data.frame(
  names=PolCit.Policy.Position.islam.not.restricted$level,
  estimate=PolCit.Policy.Position.islam.not.restricted$estimate*100,
  conf.low=PolCit.Policy.Position.islam.not.restricted$lower*100,
  conf.high=PolCit.Policy.Position.islam.not.restricted$upper*100,
  number=c("003", "001", "002", "004"))
#equal.pay.by.law
PolCit.Policy.Position.equal.pay.by.law <- mm(FGN.France, DVcho ~ samepp.equal.pay.by.law,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.equal.pay.by.lawDF <- data.frame(
  names=PolCit.Policy.Position.equal.pay.by.law$level,
  estimate=PolCit.Policy.Position.equal.pay.by.law$estimate*100,
  conf.low=PolCit.Policy.Position.equal.pay.by.law$lower*100,
  conf.high=PolCit.Policy.Position.equal.pay.by.law$upper*100,
  number=c("003", "001", "002", "004"))
#homoco.may.adopt
PolCit.Policy.Position.homoco.may.adopt <- mm(FGN.France, DVcho ~ samepp.homoco.may.adopt,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.homoco.may.adoptDF <- data.frame(
  names=PolCit.Policy.Position.homoco.may.adopt$level,
  estimate=PolCit.Policy.Position.homoco.may.adopt$estimate*100,
  conf.low=PolCit.Policy.Position.homoco.may.adopt$lower*100,
  conf.high=PolCit.Policy.Position.homoco.may.adopt$upper*100,
  number=c("003", "001", "002", "004"))

#--- Visualization

#tax.rich.higher
fig2France.tax.rich.higher <- ggplot(data = PolCit.Policy.Position.tax.rich.higherDF, 
                                     aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Taxing the rich") + 
  theme(plot.title.position = "plot")
#fig2France.tax.rich.higher

#raise.supp.unemp
fig2France.raise.supp.unemp <- ggplot(data = PolCit.Policy.Position.raise.supp.unempDF, 
                                      aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Supporting the unemployed") + 
  theme(plot.title.position = "plot")
#fig2France.raise.supp.unemp

#more.com.climcha
fig2France.more.com.climcha <- ggplot(data = PolCit.Policy.Position.more.com.climchaDF, 
                                      aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Combatting climate change") + 
  theme(plot.title.position = "plot")
#fig2France.more.com.climcha

#raise.fuel.price
fig2France.raise.fuel.price <- ggplot(data = PolCit.Policy.Position.raise.fuel.priceDF, 
                                      aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Raising fuel prices") + 
  theme(plot.title.position = "plot")
#fig2France.raise.fuel.price

#immigrants.R.asset
fig2France.immigrants.R.asset <- ggplot(data = PolCit.Policy.Position.immigrants.R.assetDF, 
                                        aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Immigrants are an asset") + 
  theme(plot.title.position = "plot")
#fig2France.immigrants.R.asset

#islam.not.restricted
fig2France.islam.not.restricted <- ggplot(data = PolCit.Policy.Position.islam.not.restrictedDF, 
                                          aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Islam should not be restricted") + 
  theme(plot.title.position = "plot")
#fig2France.islam.not.restricted

#equal.pay.by.law
fig2France.equal.pay.by.law <- ggplot(data = PolCit.Policy.Position.equal.pay.by.lawDF, 
                                      aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Gender equality, equal pay") + 
  theme(plot.title.position = "plot")
#fig2France.equal.pay.by.law

#homoco.may.adopt
fig2France.homoco.may.adopt <- ggplot(data = PolCit.Policy.Position.homoco.may.adoptDF, 
                                      aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Same-sex adoption") + 
  theme(plot.title.position = "plot")
#fig2France.homoco.may.adopt

library("patchwork")
fig2France <- fig2France.tax.rich.higher/
  fig2France.raise.supp.unemp/
  fig2France.more.com.climcha/
  fig2France.raise.fuel.price/
  fig2France.immigrants.R.asset/
  fig2France.islam.not.restricted/
  fig2France.equal.pay.by.law/
  fig2France.homoco.may.adopt +
  plot_annotation(title = 'France:\nDoes it matter whether citizen and politician share the same policy position?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. 
                  Weighted on migration background, gender, education, region and urbanization.") 
fig2France 
#ggsave(fig2France, width = 7, height = 11, file="fig2France.jpeg")  

#Germany
#policy positions
#tax.rich.higher
PolCit.Policy.Position.tax.rich.higher <- mm(FGN.Germany, DVcho ~ samepp.tax.rich.higher,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.tax.rich.higherDF <- data.frame(
  names=PolCit.Policy.Position.tax.rich.higher$level,
  estimate=PolCit.Policy.Position.tax.rich.higher$estimate*100,
  conf.low=PolCit.Policy.Position.tax.rich.higher$lower*100,
  conf.high=PolCit.Policy.Position.tax.rich.higher$upper*100,
  number=c("003", "001", "002", "004"))
#raise.supp.unemp
PolCit.Policy.Position.raise.supp.unemp <- mm(FGN.Germany, DVcho ~ samepp.raise.supp.unemp,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.raise.supp.unempDF <- data.frame(
  names=PolCit.Policy.Position.raise.supp.unemp$level,
  estimate=PolCit.Policy.Position.raise.supp.unemp$estimate*100,
  conf.low=PolCit.Policy.Position.raise.supp.unemp$lower*100,
  conf.high=PolCit.Policy.Position.raise.supp.unemp$upper*100,
  number=c("003", "001", "002", "004"))
#more.com.climcha
PolCit.Policy.Position.more.com.climcha <- mm(FGN.Germany, DVcho ~ samepp.more.com.climcha,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.more.com.climchaDF <- data.frame(
  names=PolCit.Policy.Position.more.com.climcha$level,
  estimate=PolCit.Policy.Position.more.com.climcha$estimate*100,
  conf.low=PolCit.Policy.Position.more.com.climcha$lower*100,
  conf.high=PolCit.Policy.Position.more.com.climcha$upper*100,
  number=c("003", "001", "002", "004"))
#raise.fuel.price
PolCit.Policy.Position.raise.fuel.price <- mm(FGN.Germany, DVcho ~ samepp.raise.fuel.price,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.raise.fuel.priceDF <- data.frame(
  names=PolCit.Policy.Position.raise.fuel.price$level,
  estimate=PolCit.Policy.Position.raise.fuel.price$estimate*100,
  conf.low=PolCit.Policy.Position.raise.fuel.price$lower*100,
  conf.high=PolCit.Policy.Position.raise.fuel.price$upper*100,
  number=c("003", "001", "002", "004"))
#immigrants.R.asset
PolCit.Policy.Position.immigrants.R.asset <- mm(FGN.Germany, DVcho ~ samepp.immigrants.R.asset,
                                                id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.immigrants.R.assetDF <- data.frame(
  names=PolCit.Policy.Position.immigrants.R.asset$level,
  estimate=PolCit.Policy.Position.immigrants.R.asset$estimate*100,
  conf.low=PolCit.Policy.Position.immigrants.R.asset$lower*100,
  conf.high=PolCit.Policy.Position.immigrants.R.asset$upper*100,
  number=c("003", "001", "002", "004"))
#islam.not.restricted
PolCit.Policy.Position.islam.not.restricted <- mm(FGN.Germany, DVcho ~ samepp.islam.not.restricted,
                                                  id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.islam.not.restrictedDF <- data.frame(
  names=PolCit.Policy.Position.islam.not.restricted$level,
  estimate=PolCit.Policy.Position.islam.not.restricted$estimate*100,
  conf.low=PolCit.Policy.Position.islam.not.restricted$lower*100,
  conf.high=PolCit.Policy.Position.islam.not.restricted$upper*100,
  number=c("003", "001", "002", "004"))
#equal.pay.by.law
PolCit.Policy.Position.equal.pay.by.law <- mm(FGN.Germany, DVcho ~ samepp.equal.pay.by.law,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.equal.pay.by.lawDF <- data.frame(
  names=PolCit.Policy.Position.equal.pay.by.law$level,
  estimate=PolCit.Policy.Position.equal.pay.by.law$estimate*100,
  conf.low=PolCit.Policy.Position.equal.pay.by.law$lower*100,
  conf.high=PolCit.Policy.Position.equal.pay.by.law$upper*100,
  number=c("003", "001", "002", "004"))
#homoco.may.adopt
PolCit.Policy.Position.homoco.may.adopt <- mm(FGN.Germany, DVcho ~ samepp.homoco.may.adopt,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.homoco.may.adoptDF <- data.frame(
  names=PolCit.Policy.Position.homoco.may.adopt$level,
  estimate=PolCit.Policy.Position.homoco.may.adopt$estimate*100,
  conf.low=PolCit.Policy.Position.homoco.may.adopt$lower*100,
  conf.high=PolCit.Policy.Position.homoco.may.adopt$upper*100,
  number=c("003", "001", "002", "004"))

#--- Visualization

#tax.rich.higher
fig2Germany.tax.rich.higher <- ggplot(data = PolCit.Policy.Position.tax.rich.higherDF, 
                                      aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Taxing the rich") + 
  theme(plot.title.position = "plot")
#fig2Germany.tax.rich.higher

#raise.supp.unemp
fig2Germany.raise.supp.unemp <- ggplot(data = PolCit.Policy.Position.raise.supp.unempDF, 
                                       aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Supporting the unemployed") + 
  theme(plot.title.position = "plot")
#fig2Germany.raise.supp.unemp

#more.com.climcha
fig2Germany.more.com.climcha <- ggplot(data = PolCit.Policy.Position.more.com.climchaDF, 
                                       aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Combatting climate change") + 
  theme(plot.title.position = "plot")
#fig2Germany.more.com.climcha

#raise.fuel.price
fig2Germany.raise.fuel.price <- ggplot(data = PolCit.Policy.Position.raise.fuel.priceDF, 
                                       aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Raising fuel prices") + 
  theme(plot.title.position = "plot")
#fig2Germany.raise.fuel.price

#immigrants.R.asset
fig2Germany.immigrants.R.asset <- ggplot(data = PolCit.Policy.Position.immigrants.R.assetDF, 
                                         aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Immigrants are an asset") + 
  theme(plot.title.position = "plot")
#fig2Germany.immigrants.R.asset

#islam.not.restricted
fig2Germany.islam.not.restricted <- ggplot(data = PolCit.Policy.Position.islam.not.restrictedDF, 
                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Islam should not be restricted") + 
  theme(plot.title.position = "plot")
#fig2Germany.islam.not.restricted

#equal.pay.by.law
fig2Germany.equal.pay.by.law <- ggplot(data = PolCit.Policy.Position.equal.pay.by.lawDF, 
                                       aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Gender equality, equal pay") + 
  theme(plot.title.position = "plot")
#fig2Germany.equal.pay.by.law

#homoco.may.adopt
fig2Germany.homoco.may.adopt <- ggplot(data = PolCit.Policy.Position.homoco.may.adoptDF, 
                                       aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Same-sex adoption") + 
  theme(plot.title.position = "plot")
#fig2Germany.homoco.may.adopt

library("patchwork")
fig2Germany <- fig2Germany.tax.rich.higher/
  fig2Germany.raise.supp.unemp/
  fig2Germany.more.com.climcha/
  fig2Germany.raise.fuel.price/
  fig2Germany.immigrants.R.asset/
  fig2Germany.islam.not.restricted/
  fig2Germany.equal.pay.by.law/
  fig2Germany.homoco.may.adopt +
  plot_annotation(title = 'Germany:\nDoes it matter whether citizen and politician share the same policy position?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. 
                  Weighted on migration background, gender, education, region and urbanization.") 
fig2Germany 
#ggsave(fig2Germany, width = 7, height = 11, file="fig2Germany.jpeg")  

#Netherlands
#policy positions
#tax.rich.higher
PolCit.Policy.Position.tax.rich.higher <- mm(FGN.Netherlands, DVcho ~ samepp.tax.rich.higher,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.tax.rich.higherDF <- data.frame(
  names=PolCit.Policy.Position.tax.rich.higher$level,
  estimate=PolCit.Policy.Position.tax.rich.higher$estimate*100,
  conf.low=PolCit.Policy.Position.tax.rich.higher$lower*100,
  conf.high=PolCit.Policy.Position.tax.rich.higher$upper*100,
  number=c("003", "001", "002", "004"))
#raise.supp.unemp
PolCit.Policy.Position.raise.supp.unemp <- mm(FGN.Netherlands, DVcho ~ samepp.raise.supp.unemp,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.raise.supp.unempDF <- data.frame(
  names=PolCit.Policy.Position.raise.supp.unemp$level,
  estimate=PolCit.Policy.Position.raise.supp.unemp$estimate*100,
  conf.low=PolCit.Policy.Position.raise.supp.unemp$lower*100,
  conf.high=PolCit.Policy.Position.raise.supp.unemp$upper*100,
  number=c("003", "001", "002", "004"))
#more.com.climcha
PolCit.Policy.Position.more.com.climcha <- mm(FGN.Netherlands, DVcho ~ samepp.more.com.climcha,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.more.com.climchaDF <- data.frame(
  names=PolCit.Policy.Position.more.com.climcha$level,
  estimate=PolCit.Policy.Position.more.com.climcha$estimate*100,
  conf.low=PolCit.Policy.Position.more.com.climcha$lower*100,
  conf.high=PolCit.Policy.Position.more.com.climcha$upper*100,
  number=c("003", "001", "002", "004"))
#raise.fuel.price
PolCit.Policy.Position.raise.fuel.price <- mm(FGN.Netherlands, DVcho ~ samepp.raise.fuel.price,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.raise.fuel.priceDF <- data.frame(
  names=PolCit.Policy.Position.raise.fuel.price$level,
  estimate=PolCit.Policy.Position.raise.fuel.price$estimate*100,
  conf.low=PolCit.Policy.Position.raise.fuel.price$lower*100,
  conf.high=PolCit.Policy.Position.raise.fuel.price$upper*100,
  number=c("003", "001", "002", "004"))
#immigrants.R.asset
PolCit.Policy.Position.immigrants.R.asset <- mm(FGN.Netherlands, DVcho ~ samepp.immigrants.R.asset,
                                                id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.immigrants.R.assetDF <- data.frame(
  names=PolCit.Policy.Position.immigrants.R.asset$level,
  estimate=PolCit.Policy.Position.immigrants.R.asset$estimate*100,
  conf.low=PolCit.Policy.Position.immigrants.R.asset$lower*100,
  conf.high=PolCit.Policy.Position.immigrants.R.asset$upper*100,
  number=c("003", "001", "002", "004"))
#islam.not.restricted
PolCit.Policy.Position.islam.not.restricted <- mm(FGN.Netherlands, DVcho ~ samepp.islam.not.restricted,
                                                  id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.islam.not.restrictedDF <- data.frame(
  names=PolCit.Policy.Position.islam.not.restricted$level,
  estimate=PolCit.Policy.Position.islam.not.restricted$estimate*100,
  conf.low=PolCit.Policy.Position.islam.not.restricted$lower*100,
  conf.high=PolCit.Policy.Position.islam.not.restricted$upper*100,
  number=c("003", "001", "002", "004"))
#equal.pay.by.law
PolCit.Policy.Position.equal.pay.by.law <- mm(FGN.Netherlands, DVcho ~ samepp.equal.pay.by.law,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.equal.pay.by.lawDF <- data.frame(
  names=PolCit.Policy.Position.equal.pay.by.law$level,
  estimate=PolCit.Policy.Position.equal.pay.by.law$estimate*100,
  conf.low=PolCit.Policy.Position.equal.pay.by.law$lower*100,
  conf.high=PolCit.Policy.Position.equal.pay.by.law$upper*100,
  number=c("003", "001", "002", "004"))
#homoco.may.adopt
PolCit.Policy.Position.homoco.may.adopt <- mm(FGN.Netherlands, DVcho ~ samepp.homoco.may.adopt,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.homoco.may.adoptDF <- data.frame(
  names=PolCit.Policy.Position.homoco.may.adopt$level,
  estimate=PolCit.Policy.Position.homoco.may.adopt$estimate*100,
  conf.low=PolCit.Policy.Position.homoco.may.adopt$lower*100,
  conf.high=PolCit.Policy.Position.homoco.may.adopt$upper*100,
  number=c("003", "001", "002", "004"))

#--- Visualization

#tax.rich.higher
fig2Netherlands.tax.rich.higher <- ggplot(data = PolCit.Policy.Position.tax.rich.higherDF, 
                                          aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Taxing the rich") + 
  theme(plot.title.position = "plot")
#fig2Netherlands.tax.rich.higher

#raise.supp.unemp
fig2Netherlands.raise.supp.unemp <- ggplot(data = PolCit.Policy.Position.raise.supp.unempDF, 
                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Supporting the unemployed") + 
  theme(plot.title.position = "plot")
#fig2Netherlands.raise.supp.unemp

#more.com.climcha
fig2Netherlands.more.com.climcha <- ggplot(data = PolCit.Policy.Position.more.com.climchaDF, 
                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Combatting climate change") + 
  theme(plot.title.position = "plot")
#fig2Netherlands.more.com.climcha

#raise.fuel.price
fig2Netherlands.raise.fuel.price <- ggplot(data = PolCit.Policy.Position.raise.fuel.priceDF, 
                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Raising fuel prices") + 
  theme(plot.title.position = "plot")
#fig2Netherlands.raise.fuel.price

#immigrants.R.asset
fig2Netherlands.immigrants.R.asset <- ggplot(data = PolCit.Policy.Position.immigrants.R.assetDF, 
                                             aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Immigrants are an asset") + 
  theme(plot.title.position = "plot")
#fig2Netherlands.immigrants.R.asset

#islam.not.restricted
fig2Netherlands.islam.not.restricted <- ggplot(data = PolCit.Policy.Position.islam.not.restrictedDF, 
                                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Islam should not be restricted") + 
  theme(plot.title.position = "plot")
#fig2Netherlands.islam.not.restricted

#equal.pay.by.law
fig2Netherlands.equal.pay.by.law <- ggplot(data = PolCit.Policy.Position.equal.pay.by.lawDF, 
                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Gender equality, equal pay") + 
  theme(plot.title.position = "plot")
#fig2Netherlands.equal.pay.by.law

#homoco.may.adopt
fig2Netherlands.homoco.may.adopt <- ggplot(data = PolCit.Policy.Position.homoco.may.adoptDF, 
                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Same-sex adoption") + 
  theme(plot.title.position = "plot")
#fig2Netherlands.homoco.may.adopt

library("patchwork")
fig2Netherlands <- fig2Netherlands.tax.rich.higher/
  fig2Netherlands.raise.supp.unemp/
  fig2Netherlands.more.com.climcha/
  fig2Netherlands.raise.fuel.price/
  fig2Netherlands.immigrants.R.asset/
  fig2Netherlands.islam.not.restricted/
  fig2Netherlands.equal.pay.by.law/
  fig2Netherlands.homoco.may.adopt +
  plot_annotation(title = 'Netherlands:\nDoes it matter whether citizen and politician share the same policy position?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. 
                  Weighted on migration background, gender, education, region and urbanization.") 
fig2Netherlands 
#ggsave(fig2Netherlands, width = 7, height = 11, file="fig2Netherlands.jpeg")  

#amongst Muslims
#policy positions
#tax.rich.higher
PolCit.Policy.Position.tax.rich.higher <- mm(FGN.Muslim.cit, DVcho ~ samepp.tax.rich.higher,
                                             id = ~ INTNR, h0 = 0.5)
PolCit.Policy.Position.tax.rich.higherDF <- data.frame(
  names=PolCit.Policy.Position.tax.rich.higher$level,
  estimate=PolCit.Policy.Position.tax.rich.higher$estimate*100,
  conf.low=PolCit.Policy.Position.tax.rich.higher$lower*100,
  conf.high=PolCit.Policy.Position.tax.rich.higher$upper*100,
  number=c("001", "002", "003", "004"))
PolCit.Policy.Position.tax.rich.higher
#raise.supp.unemp
PolCit.Policy.Position.raise.supp.unemp <- mm(FGN.Muslim.cit, DVcho ~ samepp.raise.supp.unemp,
                                              id = ~ INTNR, h0 = 0.5)
PolCit.Policy.Position.raise.supp.unempDF <- data.frame(
  names=PolCit.Policy.Position.raise.supp.unemp$level,
  estimate=PolCit.Policy.Position.raise.supp.unemp$estimate*100,
  conf.low=PolCit.Policy.Position.raise.supp.unemp$lower*100,
  conf.high=PolCit.Policy.Position.raise.supp.unemp$upper*100,
  number=c("001", "002", "003", "004"))
#more.com.climcha
PolCit.Policy.Position.more.com.climcha <- mm(FGN.Muslim.cit, DVcho ~ samepp.more.com.climcha,
                                              id = ~ INTNR, h0 = 0.5)
PolCit.Policy.Position.more.com.climchaDF <- data.frame(
  names=PolCit.Policy.Position.more.com.climcha$level,
  estimate=PolCit.Policy.Position.more.com.climcha$estimate*100,
  conf.low=PolCit.Policy.Position.more.com.climcha$lower*100,
  conf.high=PolCit.Policy.Position.more.com.climcha$upper*100,
  number=c("001", "002", "003", "004"))
#raise.fuel.price
PolCit.Policy.Position.raise.fuel.price <- mm(FGN.Muslim.cit, DVcho ~ samepp.raise.fuel.price,
                                              id = ~ INTNR, h0 = 0.5)
PolCit.Policy.Position.raise.fuel.priceDF <- data.frame(
  names=PolCit.Policy.Position.raise.fuel.price$level,
  estimate=PolCit.Policy.Position.raise.fuel.price$estimate*100,
  conf.low=PolCit.Policy.Position.raise.fuel.price$lower*100,
  conf.high=PolCit.Policy.Position.raise.fuel.price$upper*100,
  number=c("001", "002", "003", "004"))
#immigrants.R.asset
PolCit.Policy.Position.immigrants.R.asset <- mm(FGN.Muslim.cit, DVcho ~ samepp.immigrants.R.asset,
                                                id = ~ INTNR, h0 = 0.5)
PolCit.Policy.Position.immigrants.R.assetDF <- data.frame(
  names=PolCit.Policy.Position.immigrants.R.asset$level,
  estimate=PolCit.Policy.Position.immigrants.R.asset$estimate*100,
  conf.low=PolCit.Policy.Position.immigrants.R.asset$lower*100,
  conf.high=PolCit.Policy.Position.immigrants.R.asset$upper*100,
  number=c("001", "002", "003", "004"))
#islam.not.restricted
PolCit.Policy.Position.islam.not.restricted <- mm(FGN.Muslim.cit, DVcho ~ samepp.islam.not.restricted,
                                                  id = ~ INTNR, h0 = 0.5)
PolCit.Policy.Position.islam.not.restrictedDF <- data.frame(
  names=PolCit.Policy.Position.islam.not.restricted$level,
  estimate=PolCit.Policy.Position.islam.not.restricted$estimate*100,
  conf.low=PolCit.Policy.Position.islam.not.restricted$lower*100,
  conf.high=PolCit.Policy.Position.islam.not.restricted$upper*100,
  number=c("001", "002", "003", "004"))
#equal.pay.by.law
PolCit.Policy.Position.equal.pay.by.law <- mm(FGN.Muslim.cit, DVcho ~ samepp.equal.pay.by.law,
                                              id = ~ INTNR, h0 = 0.5)
PolCit.Policy.Position.equal.pay.by.lawDF <- data.frame(
  names=PolCit.Policy.Position.equal.pay.by.law$level,
  estimate=PolCit.Policy.Position.equal.pay.by.law$estimate*100,
  conf.low=PolCit.Policy.Position.equal.pay.by.law$lower*100,
  conf.high=PolCit.Policy.Position.equal.pay.by.law$upper*100,
  number=c("001", "002", "003", "004"))
#homoco.may.adopt
PolCit.Policy.Position.homoco.may.adopt <- mm(FGN.Muslim.cit, DVcho ~ samepp.homoco.may.adopt,
                                              id = ~ INTNR, h0 = 0.5)
PolCit.Policy.Position.homoco.may.adoptDF <- data.frame(
  names=PolCit.Policy.Position.homoco.may.adopt$level,
  estimate=PolCit.Policy.Position.homoco.may.adopt$estimate*100,
  conf.low=PolCit.Policy.Position.homoco.may.adopt$lower*100,
  conf.high=PolCit.Policy.Position.homoco.may.adopt$upper*100,
  number=c("001", "002", "003", "004"))

#--- Visualization

#tax.rich.higher
Fig2.tax.rich.higher <- ggplot(data = PolCit.Policy.Position.tax.rich.higherDF, 
                               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Taxing the rich") + 
  theme(plot.title.position = "plot")
#Fig2.tax.rich.higher

#raise.supp.unemp
Fig2.raise.supp.unemp <- ggplot(data = PolCit.Policy.Position.raise.supp.unempDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Supporting the unemployed") + 
  theme(plot.title.position = "plot")
#Fig2.raise.supp.unemp

#more.com.climcha
Fig2.more.com.climcha <- ggplot(data = PolCit.Policy.Position.more.com.climchaDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Combatting climate change") + 
  theme(plot.title.position = "plot")
#Fig2.more.com.climcha

#raise.fuel.price
Fig2.raise.fuel.price <- ggplot(data = PolCit.Policy.Position.raise.fuel.priceDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Raising fuel prices") + 
  theme(plot.title.position = "plot")
#Fig2.raise.fuel.price

#immigrants.R.asset
Fig2.immigrants.R.asset <- ggplot(data = PolCit.Policy.Position.immigrants.R.assetDF, 
                                  aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Immigrants are an asset") + 
  theme(plot.title.position = "plot")
#Fig2.immigrants.R.asset

#islam.not.restricted
Fig2.islam.not.restricted <- ggplot(data = PolCit.Policy.Position.islam.not.restrictedDF, 
                                    aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Islam should not be restricted") + 
  theme(plot.title.position = "plot")
#Fig2.islam.not.restricted

#equal.pay.by.law
Fig2.equal.pay.by.law <- ggplot(data = PolCit.Policy.Position.equal.pay.by.lawDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Gender equality, equal pay") + 
  theme(plot.title.position = "plot")
#Fig2.equal.pay.by.law

#homoco.may.adopt
Fig2.homoco.may.adopt <- ggplot(data = PolCit.Policy.Position.homoco.may.adoptDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Same-sex adoption") + 
  theme(plot.title.position = "plot")
#Fig2.homoco.may.adopt

library("patchwork")
Fig2 <- Fig2.tax.rich.higher/
  Fig2.raise.supp.unemp/
  Fig2.more.com.climcha/
  Fig2.raise.fuel.price/
  Fig2.immigrants.R.asset/
  Fig2.islam.not.restricted/
  Fig2.equal.pay.by.law/
  Fig2.homoco.may.adopt +
  plot_annotation(title = '\nAmongst Muslims - Voting likelihood when voter and politician share the same policy position:',
                  subtitle = ' ',
                  caption = "
                  Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they are most likely to vote for. Error bars
                  represent the 95% confidence interval. Confidence intervals were clustered at the level of the respondent.") 
Fig2 
##ggsave(Fig2, width = 8, height = 12, file="Muslims - policy positions matter the most to voters.jpeg")  

#amongst non-religious
#policy positions
#tax.rich.higher
PolCit.Policy.Position.tax.rich.higher <- mm(FGN.NonRel.cit, DVcho ~ samepp.tax.rich.higher,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.tax.rich.higherDF <- data.frame(
  names=PolCit.Policy.Position.tax.rich.higher$level,
  estimate=PolCit.Policy.Position.tax.rich.higher$estimate*100,
  conf.low=PolCit.Policy.Position.tax.rich.higher$lower*100,
  conf.high=PolCit.Policy.Position.tax.rich.higher$upper*100,
  number=c("001", "002", "003", "004"))
PolCit.Policy.Position.tax.rich.higher
#raise.supp.unemp
PolCit.Policy.Position.raise.supp.unemp <- mm(FGN.NonRel.cit, DVcho ~ samepp.raise.supp.unemp,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.raise.supp.unempDF <- data.frame(
  names=PolCit.Policy.Position.raise.supp.unemp$level,
  estimate=PolCit.Policy.Position.raise.supp.unemp$estimate*100,
  conf.low=PolCit.Policy.Position.raise.supp.unemp$lower*100,
  conf.high=PolCit.Policy.Position.raise.supp.unemp$upper*100,
  number=c("001", "002", "003", "004"))
#more.com.climcha
PolCit.Policy.Position.more.com.climcha <- mm(FGN.NonRel.cit, DVcho ~ samepp.more.com.climcha,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.more.com.climchaDF <- data.frame(
  names=PolCit.Policy.Position.more.com.climcha$level,
  estimate=PolCit.Policy.Position.more.com.climcha$estimate*100,
  conf.low=PolCit.Policy.Position.more.com.climcha$lower*100,
  conf.high=PolCit.Policy.Position.more.com.climcha$upper*100,
  number=c("001", "002", "003", "004"))
#raise.fuel.price
PolCit.Policy.Position.raise.fuel.price <- mm(FGN.NonRel.cit, DVcho ~ samepp.raise.fuel.price,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.raise.fuel.priceDF <- data.frame(
  names=PolCit.Policy.Position.raise.fuel.price$level,
  estimate=PolCit.Policy.Position.raise.fuel.price$estimate*100,
  conf.low=PolCit.Policy.Position.raise.fuel.price$lower*100,
  conf.high=PolCit.Policy.Position.raise.fuel.price$upper*100,
  number=c("001", "002", "003", "004"))
#immigrants.R.asset
PolCit.Policy.Position.immigrants.R.asset <- mm(FGN.NonRel.cit, DVcho ~ samepp.immigrants.R.asset,
                                                id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.immigrants.R.assetDF <- data.frame(
  names=PolCit.Policy.Position.immigrants.R.asset$level,
  estimate=PolCit.Policy.Position.immigrants.R.asset$estimate*100,
  conf.low=PolCit.Policy.Position.immigrants.R.asset$lower*100,
  conf.high=PolCit.Policy.Position.immigrants.R.asset$upper*100,
  number=c("001", "002", "003", "004"))
#islam.not.restricted
PolCit.Policy.Position.islam.not.restricted <- mm(FGN.NonRel.cit, DVcho ~ samepp.islam.not.restricted,
                                                  id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.islam.not.restrictedDF <- data.frame(
  names=PolCit.Policy.Position.islam.not.restricted$level,
  estimate=PolCit.Policy.Position.islam.not.restricted$estimate*100,
  conf.low=PolCit.Policy.Position.islam.not.restricted$lower*100,
  conf.high=PolCit.Policy.Position.islam.not.restricted$upper*100,
  number=c("001", "002", "003", "004"))
#equal.pay.by.law
PolCit.Policy.Position.equal.pay.by.law <- mm(FGN.NonRel.cit, DVcho ~ samepp.equal.pay.by.law,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.equal.pay.by.lawDF <- data.frame(
  names=PolCit.Policy.Position.equal.pay.by.law$level,
  estimate=PolCit.Policy.Position.equal.pay.by.law$estimate*100,
  conf.low=PolCit.Policy.Position.equal.pay.by.law$lower*100,
  conf.high=PolCit.Policy.Position.equal.pay.by.law$upper*100,
  number=c("001", "002", "003", "004"))
#homoco.may.adopt
PolCit.Policy.Position.homoco.may.adopt <- mm(FGN.NonRel.cit, DVcho ~ samepp.homoco.may.adopt,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Policy.Position.homoco.may.adoptDF <- data.frame(
  names=PolCit.Policy.Position.homoco.may.adopt$level,
  estimate=PolCit.Policy.Position.homoco.may.adopt$estimate*100,
  conf.low=PolCit.Policy.Position.homoco.may.adopt$lower*100,
  conf.high=PolCit.Policy.Position.homoco.may.adopt$upper*100,
  number=c("001", "002", "003", "004"))

#--- Visualization

#tax.rich.higher
Fig2.tax.rich.higher <- ggplot(data = PolCit.Policy.Position.tax.rich.higherDF, 
                               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Taxing the rich") + 
  theme(plot.title.position = "plot")
#Fig2.tax.rich.higher

#raise.supp.unemp
Fig2.raise.supp.unemp <- ggplot(data = PolCit.Policy.Position.raise.supp.unempDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Supporting the unemployed") + 
  theme(plot.title.position = "plot")
#Fig2.raise.supp.unemp

#more.com.climcha
Fig2.more.com.climcha <- ggplot(data = PolCit.Policy.Position.more.com.climchaDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Combatting climate change") + 
  theme(plot.title.position = "plot")
#Fig2.more.com.climcha

#raise.fuel.price
Fig2.raise.fuel.price <- ggplot(data = PolCit.Policy.Position.raise.fuel.priceDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Raising fuel prices") + 
  theme(plot.title.position = "plot")
#Fig2.raise.fuel.price

#immigrants.R.asset
Fig2.immigrants.R.asset <- ggplot(data = PolCit.Policy.Position.immigrants.R.assetDF, 
                                  aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Immigrants are an asset") + 
  theme(plot.title.position = "plot")
#Fig2.immigrants.R.asset

#islam.not.restricted
Fig2.islam.not.restricted <- ggplot(data = PolCit.Policy.Position.islam.not.restrictedDF, 
                                    aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Islam should not be restricted") + 
  theme(plot.title.position = "plot")
#Fig2.islam.not.restricted

#equal.pay.by.law
Fig2.equal.pay.by.law <- ggplot(data = PolCit.Policy.Position.equal.pay.by.lawDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Gender equality, equal pay") + 
  theme(plot.title.position = "plot")
#Fig2.equal.pay.by.law

#homoco.may.adopt
Fig2.homoco.may.adopt <- ggplot(data = PolCit.Policy.Position.homoco.may.adoptDF, 
                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Same-sex adoption") + 
  theme(plot.title.position = "plot")
#Fig2.homoco.may.adopt

library("patchwork")
Fig2 <- Fig2.tax.rich.higher/
  Fig2.raise.supp.unemp/
  Fig2.more.com.climcha/
  Fig2.raise.fuel.price/
  Fig2.immigrants.R.asset/
  Fig2.islam.not.restricted/
  Fig2.equal.pay.by.law/
  Fig2.homoco.may.adopt +
  plot_annotation(title = '\nNon-religious - Voting likelihood when voter and politician share the same policy position:',
                  subtitle = ' ',
                  caption = "
                  Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they are most likely to vote for. Error bars
                  represent the 95% confidence interval. Weighted on migration background, confidence intervals were clustered at the level of the respondent.") 
Fig2 
#ggsave(Fig2, width = 8, height = 12, file="Non-Religious - policy positions matter the most to voters.jpeg")  

#-------------------------------#
#--- fig3 WHEN same religion ---#
#-------------------------------#

#France
#Muslim
FGN.France.Muslim.cit <- subset(FGN.France, Citizen.Religion=="Muslim citizen")
FGN.France.Muslim.cit$PolCit.Religion.Muslim <- 
  interaction(FGN.France.Muslim.cit$Politician.Religion, sep = " + ")
PolCit.Religion.Muslim <- mm(FGN.France.Muslim.cit, DVcho ~ PolCit.Religion.Muslim,
                             id = ~ INTNR, h0 = 0.5)
PolCit.Religion.Muslim

PolCit.Muslim.citDF <- data.frame(
  names=PolCit.Religion.Muslim$level,
  estimate=PolCit.Religion.Muslim$estimate*100,
  conf.low=PolCit.Religion.Muslim$lower*100,
  conf.high=PolCit.Religion.Muslim$upper*100)

PolCit.Muslim.citDF

fig3FranceMuslim.cit <- ggplot(data = PolCit.Muslim.citDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizen +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Non-religious
FGN.France.NonRel.cit <- subset(FGN.France, Citizen.Religion=="non-religious citizen")
FGN.France.NonRel.cit$PolCit.Religion.NonRel <- 
  interaction(FGN.France.NonRel.cit$Politician.Religion, sep = " + ")
PolCit.Religion.NonRel <- mm(FGN.France.NonRel.cit, DVcho ~ PolCit.Religion.NonRel,
                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Religion.NonRel

PolCit.NonRel.citDF <- data.frame(
  names=PolCit.Religion.NonRel$level,
  estimate=PolCit.Religion.NonRel$estimate*100,
  conf.low=PolCit.Religion.NonRel$lower*100,
  conf.high=PolCit.Religion.NonRel$upper*100)

PolCit.NonRel.citDF

fig3FranceNonRel.cit <- ggplot(data = PolCit.NonRel.citDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizen +") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")


fig3France <- fig3FranceMuslim.cit/fig3FranceNonRel.cit +
  plot_annotation(title = 'France:\nWhen does it matter whether citizen and politician share the same religion?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Weighted on gender, education, region and urbanization.") 
fig3France
#ggsave(fig3France, width = 7, height = 5, file="fig3France.jpeg")  

#Germany
#Germany
#Muslim
FGN.Germany.Muslim.cit <- subset(FGN.Germany, Citizen.Religion=="Muslim citizen")
FGN.Germany.Muslim.cit$PolCit.Religion.Muslim <- 
  interaction(FGN.Germany.Muslim.cit$Politician.Religion, sep = " + ")
PolCit.Religion.Muslim <- mm(FGN.Germany.Muslim.cit, DVcho ~ PolCit.Religion.Muslim,
                             id = ~ INTNR, h0 = 0.5)
PolCit.Religion.Muslim

PolCit.Muslim.citDF <- data.frame(
  names=PolCit.Religion.Muslim$level,
  estimate=PolCit.Religion.Muslim$estimate*100,
  conf.low=PolCit.Religion.Muslim$lower*100,
  conf.high=PolCit.Religion.Muslim$upper*100)

PolCit.Muslim.citDF

fig3GermanyMuslim.cit <- ggplot(data = PolCit.Muslim.citDF, 
                                aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizen +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Non-religious
FGN.Germany.NonRel.cit <- subset(FGN.Germany, Citizen.Religion=="non-religious citizen")
FGN.Germany.NonRel.cit$PolCit.Religion.NonRel <- 
  interaction(FGN.Germany.NonRel.cit$Politician.Religion, sep = " + ")
PolCit.Religion.NonRel <- mm(FGN.Germany.NonRel.cit, DVcho ~ PolCit.Religion.NonRel,
                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Religion.NonRel

PolCit.NonRel.citDF <- data.frame(
  names=PolCit.Religion.NonRel$level,
  estimate=PolCit.Religion.NonRel$estimate*100,
  conf.low=PolCit.Religion.NonRel$lower*100,
  conf.high=PolCit.Religion.NonRel$upper*100)

PolCit.NonRel.citDF

fig3GermanyNonRel.cit <- ggplot(data = PolCit.NonRel.citDF, 
                                aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizen +") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")


fig3Germany <- fig3GermanyMuslim.cit/fig3GermanyNonRel.cit +
  plot_annotation(title = 'Germany:\nWhen does it matter whether citizen and politician share the same religion?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Weighted on gender, education, region and urbanization.") 
fig3Germany
#ggsave(fig3Germany, width = 7, height = 5, file="fig3Germany.jpeg")  

#Netherlands
#Muslim
FGN.Netherlands.Muslim.cit <- subset(FGN.Netherlands, Citizen.Religion=="Muslim citizen")
FGN.Netherlands.Muslim.cit$PolCit.Religion.Muslim <- 
  interaction(FGN.Netherlands.Muslim.cit$Politician.Religion, sep = " + ")
PolCit.Religion.Muslim <- mm(FGN.Netherlands.Muslim.cit, DVcho ~ PolCit.Religion.Muslim,
                             id = ~ INTNR, h0 = 0.5)
PolCit.Religion.Muslim

PolCit.Muslim.citDF <- data.frame(
  names=PolCit.Religion.Muslim$level,
  estimate=PolCit.Religion.Muslim$estimate*100,
  conf.low=PolCit.Religion.Muslim$lower*100,
  conf.high=PolCit.Religion.Muslim$upper*100)

PolCit.Muslim.citDF

fig3NetherlandsMuslim.cit <- ggplot(data = PolCit.Muslim.citDF, 
                                    aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizen +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Non-religious
FGN.Netherlands.NonRel.cit <- subset(FGN.Netherlands, Citizen.Religion=="non-religious citizen")
FGN.Netherlands.NonRel.cit$PolCit.Religion.NonRel <- 
  interaction(FGN.Netherlands.NonRel.cit$Politician.Religion, sep = " + ")
PolCit.Religion.NonRel <- mm(FGN.Netherlands.NonRel.cit, DVcho ~ PolCit.Religion.NonRel,
                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Religion.NonRel

PolCit.NonRel.citDF <- data.frame(
  names=PolCit.Religion.NonRel$level,
  estimate=PolCit.Religion.NonRel$estimate*100,
  conf.low=PolCit.Religion.NonRel$lower*100,
  conf.high=PolCit.Religion.NonRel$upper*100)

PolCit.NonRel.citDF

fig3NetherlandsNonRel.cit <- ggplot(data = PolCit.NonRel.citDF, 
                                    aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizen +") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")


fig3Netherlands <- fig3NetherlandsMuslim.cit/fig3NetherlandsNonRel.cit +
  plot_annotation(title = 'Netherlands:\nWhen does it matter whether citizen and politician share the same religion?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Weighted on gender, education, region and urbanization.") 
fig3Netherlands
#ggsave(fig3Netherlands, width = 7, height = 5, file="fig3Netherlands.jpeg")  

#------------------------------#
#--- Cross-pressured voters ---#
#------------------------------#

#Muslim
FGN.France.Muslim.cit <- subset(FGN.France, Citizen.Religion=="Muslim citizen")
FGN.France.Muslim.cit$PolCit.CP.Religion.Muslim <- 
  interaction(FGN.France.Muslim.cit$Politician.Religion, FGN.France.Muslim.cit$samepp, sep = " + ")
PolCit.CP.Religion.Muslim <- mm(FGN.France.Muslim.cit, DVcho ~ PolCit.CP.Religion.Muslim,
                                id = ~ INTNR, h0 = 0.5)
PolCit.CP.Religion.Muslim

PolCit.CP.Muslim.citDF <- data.frame(
  names=PolCit.CP.Religion.Muslim$level,
  estimate=PolCit.CP.Religion.Muslim$estimate*100,
  conf.low=PolCit.CP.Religion.Muslim$lower*100,
  conf.high=PolCit.CP.Religion.Muslim$upper*100)

PolCit.CP.Muslim.citDF

fig3FranceMuslim.cit <- ggplot(data = PolCit.CP.Muslim.citDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizen +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Non-religious
FGN.France.NonRel.cit <- subset(FGN.France, Citizen.Religion=="non-religious citizen")
FGN.France.NonRel.cit$PolCit.CP.Religion.NonRel <- 
  interaction(FGN.France.NonRel.cit$Politician.Religion, FGN.France.NonRel.cit$samepp,  sep = " + ")
PolCit.CP.Religion.NonRel <- mm(FGN.France.NonRel.cit, DVcho ~ PolCit.CP.Religion.NonRel,
                                id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.CP.Religion.NonRel

PolCit.CP.NonRel.citDF <- data.frame(
  names=PolCit.CP.Religion.NonRel$level,
  estimate=PolCit.CP.Religion.NonRel$estimate*100,
  conf.low=PolCit.CP.Religion.NonRel$lower*100,
  conf.high=PolCit.CP.Religion.NonRel$upper*100)

PolCit.CP.NonRel.citDF

fig3FranceNonRel.cit <- ggplot(data = PolCit.CP.NonRel.citDF, 
                               aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizen +") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

library("patchwork")
fig4France <- fig3FranceMuslim.cit/fig3FranceNonRel.cit +
  plot_annotation(title = 'France:\nWhat do cross-pressured voters do?',
                  subtitle = 'When chosing between sharing the same religion and policy, what do voters choose?',
                  caption = "
                  Error bars represent the 95% confidence interval. Weighted on gender, education, region and urbanization.") 
fig4France 
#ggsave(fig4France, width = 7, height = 7, file="fig4France.jpeg")  

#Germany
#Muslim
FGN.Germany.Muslim.cit <- subset(FGN.Germany, Citizen.Religion=="Muslim citizen")
FGN.Germany.Muslim.cit$PolCit.CP.Religion.Muslim <- 
  interaction(FGN.Germany.Muslim.cit$Politician.Religion, FGN.Germany.Muslim.cit$samepp, sep = " + ")
PolCit.CP.Religion.Muslim <- mm(FGN.Germany.Muslim.cit, DVcho ~ PolCit.CP.Religion.Muslim,
                                id = ~ INTNR, h0 = 0.5)
PolCit.CP.Religion.Muslim

PolCit.CP.Muslim.citDF <- data.frame(
  names=PolCit.CP.Religion.Muslim$level,
  estimate=PolCit.CP.Religion.Muslim$estimate*100,
  conf.low=PolCit.CP.Religion.Muslim$lower*100,
  conf.high=PolCit.CP.Religion.Muslim$upper*100)

PolCit.CP.Muslim.citDF

fig3GermanyMuslim.cit <- ggplot(data = PolCit.CP.Muslim.citDF, 
                                aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizen +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Non-religious
FGN.Germany.NonRel.cit <- subset(FGN.Germany, Citizen.Religion=="non-religious citizen")
FGN.Germany.NonRel.cit$PolCit.CP.Religion.NonRel <- 
  interaction(FGN.Germany.NonRel.cit$Politician.Religion, FGN.Germany.NonRel.cit$samepp,  sep = " + ")
PolCit.CP.Religion.NonRel <- mm(FGN.Germany.NonRel.cit, DVcho ~ PolCit.CP.Religion.NonRel,
                                id = ~ INTNR, h0 = 0.5)
PolCit.CP.Religion.NonRel

PolCit.CP.NonRel.citDF <- data.frame(
  names=PolCit.CP.Religion.NonRel$level,
  estimate=PolCit.CP.Religion.NonRel$estimate*100,
  conf.low=PolCit.CP.Religion.NonRel$lower*100,
  conf.high=PolCit.CP.Religion.NonRel$upper*100)

PolCit.CP.NonRel.citDF

fig3GermanyNonRel.cit <- ggplot(data = PolCit.CP.NonRel.citDF, 
                                aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizen +") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

library("patchwork")
fig4Germany <- fig3GermanyMuslim.cit/fig3GermanyNonRel.cit +
  plot_annotation(title = 'Germany:\nWhat do cross-pressured voters do?',
                  subtitle = 'When chosing between sharing the same religion and policy, what do voters choose?',
                  caption = "
                  Error bars represent the 95% confidence interval. Weighted on gender, education, region and urbanization.") 
fig4Germany 
#ggsave(fig4Germany, width = 7, height = 7, file="fig4Germany.jpeg")  

#Netherlands
#Muslim
FGN.Netherlands.Muslim.cit <- subset(FGN.Netherlands, Citizen.Religion=="Muslim citizen")
FGN.Netherlands.Muslim.cit$PolCit.CP.Religion.Muslim <- 
  interaction(FGN.Netherlands.Muslim.cit$Politician.Religion, FGN.Netherlands.Muslim.cit$samepp, sep = " + ")
PolCit.CP.Religion.Muslim <- mm(FGN.Netherlands.Muslim.cit, DVcho ~ PolCit.CP.Religion.Muslim,
                                id = ~ INTNR, h0 = 0.5)
PolCit.CP.Religion.Muslim

PolCit.CP.Muslim.citDF <- data.frame(
  names=PolCit.CP.Religion.Muslim$level,
  estimate=PolCit.CP.Religion.Muslim$estimate*100,
  conf.low=PolCit.CP.Religion.Muslim$lower*100,
  conf.high=PolCit.CP.Religion.Muslim$upper*100)

PolCit.CP.Muslim.citDF

fig3NetherlandsMuslim.cit <- ggplot(data = PolCit.CP.Muslim.citDF, 
                                    aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizen +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Non-religious
FGN.Netherlands.NonRel.cit <- subset(FGN.Netherlands, Citizen.Religion=="non-religious citizen")
FGN.Netherlands.NonRel.cit$PolCit.CP.Religion.NonRel <- 
  interaction(FGN.Netherlands.NonRel.cit$Politician.Religion, FGN.Netherlands.NonRel.cit$samepp,  sep = " + ")
PolCit.CP.Religion.NonRel <- mm(FGN.Netherlands.NonRel.cit, DVcho ~ PolCit.CP.Religion.NonRel,
                                id = ~ INTNR, h0 = 0.5)
PolCit.CP.Religion.NonRel

PolCit.CP.NonRel.citDF <- data.frame(
  names=PolCit.CP.Religion.NonRel$level,
  estimate=PolCit.CP.Religion.NonRel$estimate*100,
  conf.low=PolCit.CP.Religion.NonRel$lower*100,
  conf.high=PolCit.CP.Religion.NonRel$upper*100)

PolCit.CP.NonRel.citDF

fig3NetherlandsNonRel.cit <- ggplot(data = PolCit.CP.NonRel.citDF, 
                                    aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizen +") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

library("patchwork")
fig4Netherlands <- fig3NetherlandsMuslim.cit/fig3NetherlandsNonRel.cit +
  plot_annotation(title = 'Netherlands:\nWhat do cross-pressured voters do?',
                  subtitle = 'When chosing between sharing the same religion and policy, what do voters choose?',
                  caption = "
                  Error bars represent the 95% confidence interval. Weighted on gender, education, region and urbanization.") 
fig4Netherlands 
#ggsave(fig4Netherlands, width = 7, height = 7, file="fig4Netherlands.jpeg") 

#---------------------------------#
#--- appendix fig9 per country ---#
#---------------------------------#

#France
FGN.Francecit.NonRel.pol.NonRel <- subset(FGN.France, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGN.Francecit.NonRel.pol.Mus <- subset(FGN.France, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")

#raise.supp.unemp
#mm
cit.NonRel.pol.NonRel.raise.supp.unemp <- mm(FGN.Francecit.NonRel.pol.NonRel, DVcho ~ samepp.raise.supp.unemp,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.raise.supp.unemp <- mm(FGN.Francecit.NonRel.pol.Mus, DVcho ~ samepp.raise.supp.unemp,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.raise.supp.unempDF <- data.frame(
  names=cit.NonRel.pol.NonRel.raise.supp.unemp$level,
  estimate=cit.NonRel.pol.NonRel.raise.supp.unemp$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.raise.supp.unemp$lower*100,
  conf.high=cit.NonRel.pol.NonRel.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.raise.supp.unempDF <- data.frame(
  names=cit.NonRel.pol.Mus.raise.supp.unemp$level,
  estimate=cit.NonRel.pol.Mus.raise.supp.unemp$estimate*100,
  conf.low=cit.NonRel.pol.Mus.raise.supp.unemp$lower*100,
  conf.high=cit.NonRel.pol.Mus.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
raise.supp.unempDF <- rbind(cit.NonRel.pol.NonRel.raise.supp.unempDF, cit.NonRel.pol.Mus.raise.supp.unempDF)
raise.supp.unempDF <- raise.supp.unempDF[-c(2:4, 6:8), ]
raise.supp.unempDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.raise.supp.unemp <- ggplot(data = raise.supp.unempDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                               shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Supporting the unemployed") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.raise.supp.unemp

#immigrants.R.asset
#mm
cit.NonRel.pol.NonRel.immigrants.R.asset <- mm(FGN.Francecit.NonRel.pol.NonRel, DVcho ~ samepp.immigrants.R.asset,
                                               id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.immigrants.R.asset <- mm(FGN.Francecit.NonRel.pol.Mus, DVcho ~ samepp.immigrants.R.asset,
                                            id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.immigrants.R.assetDF <- data.frame(
  names=cit.NonRel.pol.NonRel.immigrants.R.asset$level,
  estimate=cit.NonRel.pol.NonRel.immigrants.R.asset$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.immigrants.R.asset$lower*100,
  conf.high=cit.NonRel.pol.NonRel.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.immigrants.R.assetDF <- data.frame(
  names=cit.NonRel.pol.Mus.immigrants.R.asset$level,
  estimate=cit.NonRel.pol.Mus.immigrants.R.asset$estimate*100,
  conf.low=cit.NonRel.pol.Mus.immigrants.R.asset$lower*100,
  conf.high=cit.NonRel.pol.Mus.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
immigrants.R.assetDF <- rbind(cit.NonRel.pol.NonRel.immigrants.R.assetDF, cit.NonRel.pol.Mus.immigrants.R.assetDF)
immigrants.R.assetDF <- immigrants.R.assetDF[-c(1:2, 4:6, 8:8), ]
immigrants.R.assetDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.immigrants.R.asset <- ggplot(data = immigrants.R.assetDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                                   shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Immigrants are an asset") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.immigrants.R.asset

#islam.not.restricted
#mm
cit.NonRel.pol.NonRel.islam.not.restricted <- mm(FGN.Francecit.NonRel.pol.NonRel, DVcho ~ samepp.islam.not.restricted,
                                                 id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.islam.not.restricted <- mm(FGN.Francecit.NonRel.pol.Mus, DVcho ~ samepp.islam.not.restricted,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.islam.not.restrictedDF <- data.frame(
  names=cit.NonRel.pol.NonRel.islam.not.restricted$level,
  estimate=cit.NonRel.pol.NonRel.islam.not.restricted$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.islam.not.restricted$lower*100,
  conf.high=cit.NonRel.pol.NonRel.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.islam.not.restrictedDF <- data.frame(
  names=cit.NonRel.pol.Mus.islam.not.restricted$level,
  estimate=cit.NonRel.pol.Mus.islam.not.restricted$estimate*100,
  conf.low=cit.NonRel.pol.Mus.islam.not.restricted$lower*100,
  conf.high=cit.NonRel.pol.Mus.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
islam.not.restrictedDF <- rbind(cit.NonRel.pol.NonRel.islam.not.restrictedDF, cit.NonRel.pol.Mus.islam.not.restrictedDF)
islam.not.restrictedDF <- islam.not.restrictedDF[-c(2:4, 6:8), ]
islam.not.restrictedDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.islam.not.restricted <- ggplot(data = islam.not.restrictedDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                                       shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Islam should not be restricted") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.islam.not.restricted

#equal.pay.by.law
#mm
cit.NonRel.pol.NonRel.equal.pay.by.law <- mm(FGN.Francecit.NonRel.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.equal.pay.by.law <- mm(FGN.Francecit.NonRel.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.NonRel.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.Mus.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.Mus.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
equal.pay.by.lawDF <- rbind(cit.NonRel.pol.NonRel.equal.pay.by.lawDF, cit.NonRel.pol.Mus.equal.pay.by.lawDF)
equal.pay.by.lawDF <- equal.pay.by.lawDF[-c(1:3, 5:7), ]
equal.pay.by.lawDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.equal.pay.by.law <- ggplot(data = equal.pay.by.lawDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                               shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Gender equality, equal pay") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "bottom") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.equal.pay.by.law

fig9 <- fig9.raise.supp.unemp/
  fig9.immigrants.R.asset/
  fig9.islam.not.restricted/
  fig9.equal.pay.by.law +
  plot_annotation(title = 'France: Non-religious voters:\nDifferences in voting likelihood between non-religious and Muslim politicians',
                  subtitle = ' ',
                  caption = "
Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they are most likely to vote for. Error
bars represent the 95% confidence interval. Weighted on migration background. Clustered confidence intervals at the level of the respondent.") 
fig9
##ggsave(fig9, width = 8, height = 6, file="France - hypocritical non-religious voters.jpeg")  

#Germany
FGN.Germanycit.NonRel.pol.NonRel <- subset(FGN.Germany, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGN.Germanycit.NonRel.pol.Mus <- subset(FGN.Germany, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")

#raise.supp.unemp
#mm
cit.NonRel.pol.NonRel.raise.supp.unemp <- mm(FGN.Germanycit.NonRel.pol.NonRel, DVcho ~ samepp.raise.supp.unemp,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.raise.supp.unemp <- mm(FGN.Germanycit.NonRel.pol.Mus, DVcho ~ samepp.raise.supp.unemp,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.raise.supp.unempDF <- data.frame(
  names=cit.NonRel.pol.NonRel.raise.supp.unemp$level,
  estimate=cit.NonRel.pol.NonRel.raise.supp.unemp$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.raise.supp.unemp$lower*100,
  conf.high=cit.NonRel.pol.NonRel.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.raise.supp.unempDF <- data.frame(
  names=cit.NonRel.pol.Mus.raise.supp.unemp$level,
  estimate=cit.NonRel.pol.Mus.raise.supp.unemp$estimate*100,
  conf.low=cit.NonRel.pol.Mus.raise.supp.unemp$lower*100,
  conf.high=cit.NonRel.pol.Mus.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
raise.supp.unempDF <- rbind(cit.NonRel.pol.NonRel.raise.supp.unempDF, cit.NonRel.pol.Mus.raise.supp.unempDF)
raise.supp.unempDF <- raise.supp.unempDF[-c(2:4, 6:8), ]
raise.supp.unempDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.raise.supp.unemp <- ggplot(data = raise.supp.unempDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                               shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Supporting the unemployed") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.raise.supp.unemp

#immigrants.R.asset
#mm
cit.NonRel.pol.NonRel.immigrants.R.asset <- mm(FGN.Germanycit.NonRel.pol.NonRel, DVcho ~ samepp.immigrants.R.asset,
                                               id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.immigrants.R.asset <- mm(FGN.Germanycit.NonRel.pol.Mus, DVcho ~ samepp.immigrants.R.asset,
                                            id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.immigrants.R.assetDF <- data.frame(
  names=cit.NonRel.pol.NonRel.immigrants.R.asset$level,
  estimate=cit.NonRel.pol.NonRel.immigrants.R.asset$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.immigrants.R.asset$lower*100,
  conf.high=cit.NonRel.pol.NonRel.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.immigrants.R.assetDF <- data.frame(
  names=cit.NonRel.pol.Mus.immigrants.R.asset$level,
  estimate=cit.NonRel.pol.Mus.immigrants.R.asset$estimate*100,
  conf.low=cit.NonRel.pol.Mus.immigrants.R.asset$lower*100,
  conf.high=cit.NonRel.pol.Mus.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
immigrants.R.assetDF <- rbind(cit.NonRel.pol.NonRel.immigrants.R.assetDF, cit.NonRel.pol.Mus.immigrants.R.assetDF)
immigrants.R.assetDF <- immigrants.R.assetDF[-c(1:2, 4:6, 8:8), ]
immigrants.R.assetDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.immigrants.R.asset <- ggplot(data = immigrants.R.assetDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                                   shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Immigrants are an asset") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.immigrants.R.asset

#islam.not.restricted
#mm
cit.NonRel.pol.NonRel.islam.not.restricted <- mm(FGN.Germanycit.NonRel.pol.NonRel, DVcho ~ samepp.islam.not.restricted,
                                                 id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.islam.not.restricted <- mm(FGN.Germanycit.NonRel.pol.Mus, DVcho ~ samepp.islam.not.restricted,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.islam.not.restrictedDF <- data.frame(
  names=cit.NonRel.pol.NonRel.islam.not.restricted$level,
  estimate=cit.NonRel.pol.NonRel.islam.not.restricted$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.islam.not.restricted$lower*100,
  conf.high=cit.NonRel.pol.NonRel.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.islam.not.restrictedDF <- data.frame(
  names=cit.NonRel.pol.Mus.islam.not.restricted$level,
  estimate=cit.NonRel.pol.Mus.islam.not.restricted$estimate*100,
  conf.low=cit.NonRel.pol.Mus.islam.not.restricted$lower*100,
  conf.high=cit.NonRel.pol.Mus.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
islam.not.restrictedDF <- rbind(cit.NonRel.pol.NonRel.islam.not.restrictedDF, cit.NonRel.pol.Mus.islam.not.restrictedDF)
islam.not.restrictedDF <- islam.not.restrictedDF[-c(2:4, 6:8), ]
islam.not.restrictedDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.islam.not.restricted <- ggplot(data = islam.not.restrictedDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                                       shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Islam should not be restricted") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.islam.not.restricted

#equal.pay.by.law
#mm
cit.NonRel.pol.NonRel.equal.pay.by.law <- mm(FGN.Germanycit.NonRel.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.equal.pay.by.law <- mm(FGN.Germanycit.NonRel.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.NonRel.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.Mus.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.Mus.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
equal.pay.by.lawDF <- rbind(cit.NonRel.pol.NonRel.equal.pay.by.lawDF, cit.NonRel.pol.Mus.equal.pay.by.lawDF)
equal.pay.by.lawDF <- equal.pay.by.lawDF[-c(1:3, 5:7), ]
equal.pay.by.lawDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.equal.pay.by.law <- ggplot(data = equal.pay.by.lawDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                               shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Gender equality, equal pay") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "bottom") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.equal.pay.by.law

fig9 <- fig9.raise.supp.unemp/
  fig9.immigrants.R.asset/
  fig9.islam.not.restricted/
  fig9.equal.pay.by.law +
  plot_annotation(title = 'Germany: Non-religious voters:\nDifferences in voting likelihood between non-religious and Muslim politicians',
                  subtitle = ' ',
                  caption = "
Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they are most likely to vote for. Error
bars represent the 95% confidence interval. Weighted on migration background. Clustered confidence intervals at the level of the respondent.") 
fig9
##ggsave(fig9, width = 8, height = 6, file="Germany - hypocritical non-religious voters.jpeg")  

#Netherlands
FGN.Netherlandscit.NonRel.pol.NonRel <- subset(FGN.Netherlands, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGN.Netherlandscit.NonRel.pol.Mus <- subset(FGN.Netherlands, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")

#raise.supp.unemp
#mm
cit.NonRel.pol.NonRel.raise.supp.unemp <- mm(FGN.Netherlandscit.NonRel.pol.NonRel, DVcho ~ samepp.raise.supp.unemp,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.raise.supp.unemp <- mm(FGN.Netherlandscit.NonRel.pol.Mus, DVcho ~ samepp.raise.supp.unemp,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.raise.supp.unempDF <- data.frame(
  names=cit.NonRel.pol.NonRel.raise.supp.unemp$level,
  estimate=cit.NonRel.pol.NonRel.raise.supp.unemp$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.raise.supp.unemp$lower*100,
  conf.high=cit.NonRel.pol.NonRel.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.raise.supp.unempDF <- data.frame(
  names=cit.NonRel.pol.Mus.raise.supp.unemp$level,
  estimate=cit.NonRel.pol.Mus.raise.supp.unemp$estimate*100,
  conf.low=cit.NonRel.pol.Mus.raise.supp.unemp$lower*100,
  conf.high=cit.NonRel.pol.Mus.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
raise.supp.unempDF <- rbind(cit.NonRel.pol.NonRel.raise.supp.unempDF, cit.NonRel.pol.Mus.raise.supp.unempDF)
raise.supp.unempDF <- raise.supp.unempDF[-c(2:4, 6:8), ]
raise.supp.unempDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.raise.supp.unemp <- ggplot(data = raise.supp.unempDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                               shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Supporting the unemployed") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.raise.supp.unemp

#immigrants.R.asset
#mm
cit.NonRel.pol.NonRel.immigrants.R.asset <- mm(FGN.Netherlandscit.NonRel.pol.NonRel, DVcho ~ samepp.immigrants.R.asset,
                                               id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.immigrants.R.asset <- mm(FGN.Netherlandscit.NonRel.pol.Mus, DVcho ~ samepp.immigrants.R.asset,
                                            id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.immigrants.R.assetDF <- data.frame(
  names=cit.NonRel.pol.NonRel.immigrants.R.asset$level,
  estimate=cit.NonRel.pol.NonRel.immigrants.R.asset$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.immigrants.R.asset$lower*100,
  conf.high=cit.NonRel.pol.NonRel.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.immigrants.R.assetDF <- data.frame(
  names=cit.NonRel.pol.Mus.immigrants.R.asset$level,
  estimate=cit.NonRel.pol.Mus.immigrants.R.asset$estimate*100,
  conf.low=cit.NonRel.pol.Mus.immigrants.R.asset$lower*100,
  conf.high=cit.NonRel.pol.Mus.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
immigrants.R.assetDF <- rbind(cit.NonRel.pol.NonRel.immigrants.R.assetDF, cit.NonRel.pol.Mus.immigrants.R.assetDF)
immigrants.R.assetDF <- immigrants.R.assetDF[-c(1:2, 4:6, 8:8), ]
immigrants.R.assetDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.immigrants.R.asset <- ggplot(data = immigrants.R.assetDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                                   shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Immigrants are an asset") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.immigrants.R.asset

#islam.not.restricted
#mm
cit.NonRel.pol.NonRel.islam.not.restricted <- mm(FGN.Netherlandscit.NonRel.pol.NonRel, DVcho ~ samepp.islam.not.restricted,
                                                 id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.islam.not.restricted <- mm(FGN.Netherlandscit.NonRel.pol.Mus, DVcho ~ samepp.islam.not.restricted,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.islam.not.restrictedDF <- data.frame(
  names=cit.NonRel.pol.NonRel.islam.not.restricted$level,
  estimate=cit.NonRel.pol.NonRel.islam.not.restricted$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.islam.not.restricted$lower*100,
  conf.high=cit.NonRel.pol.NonRel.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.islam.not.restrictedDF <- data.frame(
  names=cit.NonRel.pol.Mus.islam.not.restricted$level,
  estimate=cit.NonRel.pol.Mus.islam.not.restricted$estimate*100,
  conf.low=cit.NonRel.pol.Mus.islam.not.restricted$lower*100,
  conf.high=cit.NonRel.pol.Mus.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
islam.not.restrictedDF <- rbind(cit.NonRel.pol.NonRel.islam.not.restrictedDF, cit.NonRel.pol.Mus.islam.not.restrictedDF)
islam.not.restrictedDF <- islam.not.restrictedDF[-c(2:4, 6:8), ]
islam.not.restrictedDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.islam.not.restricted <- ggplot(data = islam.not.restrictedDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                                       shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Islam should not be restricted") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "none") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.islam.not.restricted

#equal.pay.by.law
#mm
cit.NonRel.pol.NonRel.equal.pay.by.law <- mm(FGN.Netherlandscit.NonRel.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.equal.pay.by.law <- mm(FGN.Netherlandscit.NonRel.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)

#making df
cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.NonRel.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.Mus.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.Mus.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"))

# Combine the two dataframes
equal.pay.by.lawDF <- rbind(cit.NonRel.pol.NonRel.equal.pay.by.lawDF, cit.NonRel.pol.Mus.equal.pay.by.lawDF)
equal.pay.by.lawDF <- equal.pay.by.lawDF[-c(1:3, 5:7), ]
equal.pay.by.lawDF$Legend <- c("Non-religious politician", "Muslim politician")

# ggplot
fig9.equal.pay.by.law <- ggplot(data = equal.pay.by.lawDF, aes(x = estimate, y = reorder(names, desc(number)), 
                                                               shape = Legend, linetype = Legend)) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Gender equality, equal pay") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-20, 120) +
  theme(plot.title.position = "plot", legend.position = "bottom") +
  scale_shape_manual(values = shapes) +
  scale_linetype_manual(values = linetypes)
#fig9.equal.pay.by.law

fig9 <- fig9.raise.supp.unemp/
  fig9.immigrants.R.asset/
  fig9.islam.not.restricted/
  fig9.equal.pay.by.law +
  plot_annotation(title = 'Netherlands: Non-religious voters:\nDifferences in voting likelihood between non-religious and Muslim politicians',
                  subtitle = ' ',
                  caption = "
Results of a forced-choice conjoint experiment asking respondents which one out of two politicians they are most likely to vote for. Error
bars represent the 95% confidence interval. Weighted on migration background. Clustered confidence intervals at the level of the respondent.") 
fig9
##ggsave(fig9, width = 8, height = 6, file="Netherlands - hypocritical non-religious voters.jpeg")  

#------------#
#--- fig5 ---# DVcho
#------------#
FGN.dk <- subset(FGN, samepp.dk == "don't know")

#with weights
#Religion H2b
PolCit.samerel <- mm(FGN.dk, DVcho ~ samerel,
                     id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.ReligionDF <- data.frame(
  names=PolCit.samerel$level,
  estimate=PolCit.samerel$estimate*100,
  conf.low=PolCit.samerel$lower*100,
  conf.high=PolCit.samerel$upper*100,
  number=c("001", "002"))
fig5religion <- ggplot(data = PolCit.ReligionDF, 
                       aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...religion?") + 
  theme(plot.title.position = "plot")
#fig5religion

#Ethnorace H2a
PolCit.sameeth <- mm(FGN.dk, DVcho ~ sameeth,
                     id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.EthnoraceDF <- data.frame(
  names=PolCit.sameeth$level,
  estimate=PolCit.sameeth$estimate*100,
  conf.low=PolCit.sameeth$lower*100,
  conf.high=PolCit.sameeth$upper*100,
  number=c("001", "002"))
fig5Ethnorace <- ggplot(data = PolCit.EthnoraceDF, 
                        aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...migration background?") + 
  theme(plot.title.position = "plot")
#fig5Ethnorace

#Gender H2c
PolCit.samegen <- mm(FGN.dk, DVcho ~ samegen,
                     id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.GenderDF <- data.frame(
  names=PolCit.samegen$level,
  estimate=PolCit.samegen$estimate*100,
  conf.low=PolCit.samegen$lower*100,
  conf.high=PolCit.samegen$upper*100,
  number=c("001", "002"))
fig5Gender <- ggplot(data = PolCit.GenderDF, 
                     aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...gender?") + 
  theme(plot.title.position = "plot")
#fig5Gender

library("patchwork")
fig5 <- fig5religion/fig5Ethnorace/fig5Gender +
  plot_annotation(title = 'WITH WEIGHTS: Amongst voters who do not know what policy position they stand for,\ndoes it matter whether citizen and politician share the same...',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Weighted on migration background") 
fig5 

#with weights
#Religion H2b
PolCit.samerel <- mm(FGN.dk, DVcho ~ samerel,
                     id = ~ INTNR, h0 = 0.5)
PolCit.ReligionDF <- data.frame(
  names=PolCit.samerel$level,
  estimate=PolCit.samerel$estimate*100,
  conf.low=PolCit.samerel$lower*100,
  conf.high=PolCit.samerel$upper*100,
  number=c("001", "002"))
fig5religion <- ggplot(data = PolCit.ReligionDF, 
                       aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...religion?") + 
  theme(plot.title.position = "plot")
#fig5religion

#Ethnorace H2a
PolCit.sameeth <- mm(FGN.dk, DVcho ~ sameeth,
                     id = ~ INTNR, h0 = 0.5)
PolCit.EthnoraceDF <- data.frame(
  names=PolCit.sameeth$level,
  estimate=PolCit.sameeth$estimate*100,
  conf.low=PolCit.sameeth$lower*100,
  conf.high=PolCit.sameeth$upper*100,
  number=c("001", "002"))
fig5Ethnorace <- ggplot(data = PolCit.EthnoraceDF, 
                        aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...migration background?") + 
  theme(plot.title.position = "plot")
#fig5Ethnorace

#Gender H2c
PolCit.samegen <- mm(FGN.dk, DVcho ~ samegen,
                     id = ~ INTNR, h0 = 0.5)
PolCit.GenderDF <- data.frame(
  names=PolCit.samegen$level,
  estimate=PolCit.samegen$estimate*100,
  conf.low=PolCit.samegen$lower*100,
  conf.high=PolCit.samegen$upper*100,
  number=c("001", "002"))
fig5Gender <- ggplot(data = PolCit.GenderDF, 
                     aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "...gender?") + 
  theme(plot.title.position = "plot")
#fig5Gender

library("patchwork")
fig5 <- fig5religion/fig5Ethnorace/fig5Gender +
  plot_annotation(title = 'WITHOUT WEIGHTS: Amongst voters who do not know what policy position they stand for,\ndoes it matter whether citizen and politician share the same...',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval.") 
fig5 

#--------------------------------#
#--- fig6 WHEN same religion ---#
#--------------------------------#

#Muslim
FGN.dk.Muslim.cit <- subset(FGN.dk, Citizen.Religion=="Muslim citizen")
FGN.dk.Muslim.cit$PolCit.Religion.Muslim <- 
  interaction(FGN.dk.Muslim.cit$Politician.Religion, sep = " + ")
PolCit.Religion.Muslim <- mm(FGN.dk.Muslim.cit, DVcho ~ PolCit.Religion.Muslim,
                             id = ~ INTNR, h0 = 0.5)
PolCit.Religion.Muslim

PolCit.Muslim.citDF <- data.frame(
  names=PolCit.Religion.Muslim$level,
  estimate=PolCit.Religion.Muslim$estimate*100,
  conf.low=PolCit.Religion.Muslim$lower*100,
  conf.high=PolCit.Religion.Muslim$upper*100)

PolCit.Muslim.citDF

fig6Muslim.cit <- ggplot(data = PolCit.Muslim.citDF, 
                         aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizen +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Christian
FGN.dk.Christian.cit <- subset(FGN.dk, Citizen.Religion=="Christian citizen")
FGN.dk.Christian.cit$PolCit.Religion.Christian <- 
  interaction(FGN.dk.Christian.cit$Politician.Religion, sep = " + ")
PolCit.Religion.Christian <- mm(FGN.dk.Christian.cit, DVcho ~ PolCit.Religion.Christian,
                                id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Religion.Christian

PolCit.Christian.citDF <- data.frame(
  names=PolCit.Religion.Christian$level,
  estimate=PolCit.Religion.Christian$estimate*100,
  conf.low=PolCit.Religion.Christian$lower*100,
  conf.high=PolCit.Religion.Christian$upper*100)

PolCit.Christian.citDF

fig6Christian.cit <- ggplot(data = PolCit.Christian.citDF, 
                            aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Christian citizen +") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Non-religious
FGN.dk.NonRel.cit <- subset(FGN.dk, Citizen.Religion=="non-religious citizen")
FGN.dk.NonRel.cit$PolCit.Religion.NonRel <- 
  interaction(FGN.dk.NonRel.cit$Politician.Religion, sep = " + ")
PolCit.Religion.NonRel <- mm(FGN.dk.NonRel.cit, DVcho ~ PolCit.Religion.NonRel,
                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Religion.NonRel

PolCit.NonRel.citDF <- data.frame(
  names=PolCit.Religion.NonRel$level,
  estimate=PolCit.Religion.NonRel$estimate*100,
  conf.low=PolCit.Religion.NonRel$lower*100,
  conf.high=PolCit.Religion.NonRel$upper*100)

PolCit.NonRel.citDF

fig6NonRel.cit <- ggplot(data = PolCit.NonRel.citDF, 
                         aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizen +") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(14, 86) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

fig6 <- fig6Muslim.cit/fig6Christian.cit/fig6NonRel.cit +
  plot_annotation(title = 'Amongst voters who do not know what policy position they stand for,\nwhen does it matter whether citizen and politician share the same religion?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Weighted on gender, education, region and urbanization.") 
fig6

#--------------------------------------------------------------------#
#--- fig9fem - Do citizens assess female politicians differently? ---# 
#--------------------------------------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician" & Politician.Gender=="Female politician")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician" & Politician.Gender=="Female politician")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician" & Politician.Gender=="Female politician")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician" & Politician.Gender=="Female politician")

#equal.pay.by.law
#mm
cit.NonRel.pol.NonRel.equal.pay.by.law <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                             id = ~ INTNR, h0 = 0.5)
cit.NonRel.pol.Mus.equal.pay.by.law <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.Mus.equal.pay.by.law <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                       id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.equal.pay.by.law <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.NonRel.equal.pay.by.law$upper*100)

cit.NonRel.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.Mus.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.Mus.equal.pay.by.law$upper*100)

cit.Mus.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.Mus.pol.Mus.equal.pay.by.law$level,
  estimate=cit.Mus.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.Mus.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.Mus.pol.Mus.equal.pay.by.law$upper*100)

cit.Mus.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.Mus.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.Mus.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.Mus.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.Mus.pol.NonRel.equal.pay.by.law$upper*100)

#ggplot
fig9fem.cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- ggplot(data = cit.NonRel.pol.NonRel.equal.pay.by.lawDF, 
                                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing female non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 120) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9fem.cit.NonRel.pol.NonRel.equal.pay.by.lawDF
fig9fem.cit.NonRel.pol.Mus.equal.pay.by.lawDF <- ggplot(data = cit.NonRel.pol.Mus.equal.pay.by.lawDF, 
                                                        aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing female Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 120) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9fem.cit.NonRel.pol.Mus.equal.pay.by.lawDF
fig9fem.cit.Mus.pol.Mus.equal.pay.by.lawDF <- ggplot(data = cit.Mus.pol.Mus.equal.pay.by.lawDF, 
                                                     aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing female Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 120) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9fem.cit.Mus.pol.Mus.equal.pay.by.lawDF
fig9fem.cit.Mus.pol.NonRel.equal.pay.by.lawDF <- ggplot(data = cit.Mus.pol.NonRel.equal.pay.by.lawDF, 
                                                        aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing female non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 120) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9fem.cit.Mus.pol.NonRel.equal.pay.by.lawDF

fig9fem <- fig9fem.cit.NonRel.pol.NonRel.equal.pay.by.lawDF/fig9fem.cit.NonRel.pol.Mus.equal.pay.by.lawDF/fig9fem.cit.Mus.pol.Mus.equal.pay.by.lawDF/fig9fem.cit.Mus.pol.NonRel.equal.pay.by.lawDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on\ngender equality? If the politician is female',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. 
                  Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. 
                  Weighted on gender, education, region and urbanization.") 
fig9fem

#------------------------------------------------------------------#
#--- fig9mal - Do citizens assess male politicians differently? ---# 
#------------------------------------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician" & Politician.Gender=="Male politician")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician" & Politician.Gender=="Male politician")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician" & Politician.Gender=="Male politician")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician" & Politician.Gender=="Male politician")

#equal.pay.by.law
#mm
cit.NonRel.pol.NonRel.equal.pay.by.law <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                             id = ~ INTNR, h0 = 0.5)
cit.NonRel.pol.Mus.equal.pay.by.law <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.Mus.equal.pay.by.law <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                       id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.equal.pay.by.law <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.NonRel.equal.pay.by.law$upper*100)

cit.NonRel.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.Mus.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.Mus.equal.pay.by.law$upper*100)

cit.Mus.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.Mus.pol.Mus.equal.pay.by.law$level,
  estimate=cit.Mus.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.Mus.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.Mus.pol.Mus.equal.pay.by.law$upper*100)

cit.Mus.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.Mus.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.Mus.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.Mus.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.Mus.pol.NonRel.equal.pay.by.law$upper*100)

#ggplot
fig9mal.cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- ggplot(data = cit.NonRel.pol.NonRel.equal.pay.by.lawDF, 
                                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing male non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9mal.cit.NonRel.pol.NonRel.equal.pay.by.lawDF
fig9mal.cit.NonRel.pol.Mus.equal.pay.by.lawDF <- ggplot(data = cit.NonRel.pol.Mus.equal.pay.by.lawDF, 
                                                        aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing male Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9mal.cit.NonRel.pol.Mus.equal.pay.by.lawDF
fig9mal.cit.Mus.pol.Mus.equal.pay.by.lawDF <- ggplot(data = cit.Mus.pol.Mus.equal.pay.by.lawDF, 
                                                     aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing male Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9mal.cit.Mus.pol.Mus.equal.pay.by.lawDF
fig9mal.cit.Mus.pol.NonRel.equal.pay.by.lawDF <- ggplot(data = cit.Mus.pol.NonRel.equal.pay.by.lawDF, 
                                                        aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing male non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9mal.cit.Mus.pol.NonRel.equal.pay.by.lawDF

fig9mal <- fig9mal.cit.NonRel.pol.NonRel.equal.pay.by.lawDF/fig9mal.cit.NonRel.pol.Mus.equal.pay.by.lawDF/fig9mal.cit.Mus.pol.Mus.equal.pay.by.lawDF/fig9mal.cit.Mus.pol.NonRel.equal.pay.by.lawDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on\ngender equality? When the politician is male',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. 
                  Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. 
                  Weighted on gender, education, region and urbanization.") 
fig9mal

#-----------------------------------------------------------------------#
#--- fig9femcit - Do female citizens assess politicians differently? ---# 
#-----------------------------------------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician" & Citizen.Gender=="Female citizen")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician" & Citizen.Gender=="Female citizen")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician" & Citizen.Gender=="Female citizen")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician" & Citizen.Gender=="Female citizen")

#equal.pay.by.law
#mm
cit.NonRel.pol.NonRel.equal.pay.by.law <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                             id = ~ INTNR, h0 = 0.5)
cit.NonRel.pol.Mus.equal.pay.by.law <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.Mus.equal.pay.by.law <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                       id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.equal.pay.by.law <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.NonRel.equal.pay.by.law$upper*100)

cit.NonRel.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.Mus.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.Mus.equal.pay.by.law$upper*100)

cit.Mus.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.Mus.pol.Mus.equal.pay.by.law$level,
  estimate=cit.Mus.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.Mus.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.Mus.pol.Mus.equal.pay.by.law$upper*100)

cit.Mus.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.Mus.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.Mus.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.Mus.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.Mus.pol.NonRel.equal.pay.by.law$upper*100)

#ggplot
fig9femcit.cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- ggplot(data = cit.NonRel.pol.NonRel.equal.pay.by.lawDF, 
                                                              aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Female non-religious citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9femcit.cit.NonRel.pol.NonRel.equal.pay.by.lawDF
fig9femcit.cit.NonRel.pol.Mus.equal.pay.by.lawDF <- ggplot(data = cit.NonRel.pol.Mus.equal.pay.by.lawDF, 
                                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Female non-religious citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9femcit.cit.NonRel.pol.Mus.equal.pay.by.lawDF
fig9femcit.cit.Mus.pol.Mus.equal.pay.by.lawDF <- ggplot(data = cit.Mus.pol.Mus.equal.pay.by.lawDF, 
                                                        aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Female Muslim citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9femcit.cit.Mus.pol.Mus.equal.pay.by.lawDF
fig9femcit.cit.Mus.pol.NonRel.equal.pay.by.lawDF <- ggplot(data = cit.Mus.pol.NonRel.equal.pay.by.lawDF, 
                                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Female Muslim citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9femcit.cit.Mus.pol.NonRel.equal.pay.by.lawDF

fig9femcit <- fig9femcit.cit.NonRel.pol.NonRel.equal.pay.by.lawDF/fig9femcit.cit.NonRel.pol.Mus.equal.pay.by.lawDF/fig9femcit.cit.Mus.pol.Mus.equal.pay.by.lawDF/fig9femcit.cit.Mus.pol.NonRel.equal.pay.by.lawDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on\ngender equality? When the citizen is female',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. 
                  Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. 
                  Weighted on gender, education, region and urbanization.") 
fig9femcit

#---------------------------------------------------------------------#
#--- fig9malcit - Do male citizens assess politicians differently? ---# 
#---------------------------------------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician" & Citizen.Gender=="Male citizen")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician" & Citizen.Gender=="Male citizen")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician" & Citizen.Gender=="Male citizen")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician" & Citizen.Gender=="Male citizen")

#equal.pay.by.law
#mm
cit.NonRel.pol.NonRel.equal.pay.by.law <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                             id = ~ INTNR, h0 = 0.5)
cit.NonRel.pol.Mus.equal.pay.by.law <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.Mus.equal.pay.by.law <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                       id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.equal.pay.by.law <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.NonRel.equal.pay.by.law$upper*100)

cit.NonRel.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.Mus.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.Mus.equal.pay.by.law$upper*100)

cit.Mus.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.Mus.pol.Mus.equal.pay.by.law$level,
  estimate=cit.Mus.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.Mus.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.Mus.pol.Mus.equal.pay.by.law$upper*100)

cit.Mus.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.Mus.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.Mus.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.Mus.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.Mus.pol.NonRel.equal.pay.by.law$upper*100)

#ggplot
fig9malcit.cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- ggplot(data = cit.NonRel.pol.NonRel.equal.pay.by.lawDF, 
                                                              aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Male non-religious citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9malcit.cit.NonRel.pol.NonRel.equal.pay.by.lawDF
fig9malcit.cit.NonRel.pol.Mus.equal.pay.by.lawDF <- ggplot(data = cit.NonRel.pol.Mus.equal.pay.by.lawDF, 
                                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Male non-religious citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9malcit.cit.NonRel.pol.Mus.equal.pay.by.lawDF
fig9malcit.cit.Mus.pol.Mus.equal.pay.by.lawDF <- ggplot(data = cit.Mus.pol.Mus.equal.pay.by.lawDF, 
                                                        aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Male Muslim citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9malcit.cit.Mus.pol.Mus.equal.pay.by.lawDF
fig9malcit.cit.Mus.pol.NonRel.equal.pay.by.lawDF <- ggplot(data = cit.Mus.pol.NonRel.equal.pay.by.lawDF, 
                                                           aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Male Muslim citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig9malcit.cit.Mus.pol.NonRel.equal.pay.by.lawDF

fig9malcit <- fig9malcit.cit.NonRel.pol.NonRel.equal.pay.by.lawDF/fig9malcit.cit.NonRel.pol.Mus.equal.pay.by.lawDF/fig9malcit.cit.Mus.pol.Mus.equal.pay.by.lawDF/fig9malcit.cit.Mus.pol.NonRel.equal.pay.by.lawDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on\ngender equality? When the citizen is male',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. 
                  Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. 
                  Weighted on gender, education, region and urbanization.") 
fig9malcit

#-------------------------------------------------------------#
#--- sharing the same policy position, per policy position ---#
#-------------------------------------------------------------#

#--------------------------------------------#
#--- cross pressured on tax.rich.higher? ---#
#--------------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")

#tax.rich.higher
#mm
cit.NonRel.pol.NonRel.tax.rich.higher <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.tax.rich.higher,
                                            id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.tax.rich.higher <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.tax.rich.higher,
                                         id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.Mus.pol.Mus.tax.rich.higher <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.tax.rich.higher,
                                      id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.tax.rich.higher <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.tax.rich.higher,
                                         id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.tax.rich.higherDF <- data.frame(
  names=cit.NonRel.pol.NonRel.tax.rich.higher$level,
  estimate=cit.NonRel.pol.NonRel.tax.rich.higher$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.tax.rich.higher$lower*100,
  conf.high=cit.NonRel.pol.NonRel.tax.rich.higher$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.tax.rich.higherDF <- data.frame(
  names=cit.NonRel.pol.Mus.tax.rich.higher$level,
  estimate=cit.NonRel.pol.Mus.tax.rich.higher$estimate*100,
  conf.low=cit.NonRel.pol.Mus.tax.rich.higher$lower*100,
  conf.high=cit.NonRel.pol.Mus.tax.rich.higher$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.Mus.tax.rich.higherDF <- data.frame(
  names=cit.Mus.pol.Mus.tax.rich.higher$level,
  estimate=cit.Mus.pol.Mus.tax.rich.higher$estimate*100,
  conf.low=cit.Mus.pol.Mus.tax.rich.higher$lower*100,
  conf.high=cit.Mus.pol.Mus.tax.rich.higher$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.NonRel.tax.rich.higherDF <- data.frame(
  names=cit.Mus.pol.NonRel.tax.rich.higher$level,
  estimate=cit.Mus.pol.NonRel.tax.rich.higher$estimate*100,
  conf.low=cit.Mus.pol.NonRel.tax.rich.higher$lower*100,
  conf.high=cit.Mus.pol.NonRel.tax.rich.higher$upper*100,  number=c("001", "002", "003", "004"))

#ggplot
fig10.cit.NonRel.pol.NonRel.tax.rich.higherDF <- ggplot(data = cit.NonRel.pol.NonRel.tax.rich.higherDF, 
                                                       aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig10.cit.NonRel.pol.NonRel.tax.rich.higherDF
fig10.cit.NonRel.pol.Mus.tax.rich.higherDF <- ggplot(data = cit.NonRel.pol.Mus.tax.rich.higherDF, 
                                                    aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig10.cit.NonRel.pol.Mus.tax.rich.higherDF
fig10.cit.Mus.pol.Mus.tax.rich.higherDF <- ggplot(data = cit.Mus.pol.Mus.tax.rich.higherDF, 
                                                 aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig10.cit.Mus.pol.Mus.tax.rich.higherDF
fig10.cit.Mus.pol.NonRel.tax.rich.higherDF <- ggplot(data = cit.Mus.pol.NonRel.tax.rich.higherDF, 
                                                    aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig10.cit.Mus.pol.NonRel.tax.rich.higherDF

fig10 <- fig10.cit.NonRel.pol.NonRel.tax.rich.higherDF/fig10.cit.NonRel.pol.Mus.tax.rich.higherDF/fig10.cit.Mus.pol.Mus.tax.rich.higherDF/fig10.cit.Mus.pol.NonRel.tax.rich.higherDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on 
taxing the rich?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. Weighted on gender, education, region and urbanization.") 
fig10

#--------------------------------------------#
#--- cross pressured on raise.supp.unemp? ---#
#--------------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")

#raise.supp.unemp
#mm
cit.NonRel.pol.NonRel.raise.supp.unemp <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.raise.supp.unemp,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.raise.supp.unemp <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.raise.supp.unemp,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.Mus.pol.Mus.raise.supp.unemp <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.raise.supp.unemp,
                                       id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.raise.supp.unemp <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.raise.supp.unemp,
                                          id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.raise.supp.unempDF <- data.frame(
  names=cit.NonRel.pol.NonRel.raise.supp.unemp$level,
  estimate=cit.NonRel.pol.NonRel.raise.supp.unemp$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.raise.supp.unemp$lower*100,
  conf.high=cit.NonRel.pol.NonRel.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.raise.supp.unempDF <- data.frame(
  names=cit.NonRel.pol.Mus.raise.supp.unemp$level,
  estimate=cit.NonRel.pol.Mus.raise.supp.unemp$estimate*100,
  conf.low=cit.NonRel.pol.Mus.raise.supp.unemp$lower*100,
  conf.high=cit.NonRel.pol.Mus.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.Mus.raise.supp.unempDF <- data.frame(
  names=cit.Mus.pol.Mus.raise.supp.unemp$level,
  estimate=cit.Mus.pol.Mus.raise.supp.unemp$estimate*100,
  conf.low=cit.Mus.pol.Mus.raise.supp.unemp$lower*100,
  conf.high=cit.Mus.pol.Mus.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.NonRel.raise.supp.unempDF <- data.frame(
  names=cit.Mus.pol.NonRel.raise.supp.unemp$level,
  estimate=cit.Mus.pol.NonRel.raise.supp.unemp$estimate*100,
  conf.low=cit.Mus.pol.NonRel.raise.supp.unemp$lower*100,
  conf.high=cit.Mus.pol.NonRel.raise.supp.unemp$upper*100,  number=c("001", "002", "003", "004"))

#ggplot
fig11.cit.NonRel.pol.NonRel.raise.supp.unempDF <- ggplot(data = cit.NonRel.pol.NonRel.raise.supp.unempDF, 
                                                        aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig11.cit.NonRel.pol.NonRel.raise.supp.unempDF
fig11.cit.NonRel.pol.Mus.raise.supp.unempDF <- ggplot(data = cit.NonRel.pol.Mus.raise.supp.unempDF, 
                                                     aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig11.cit.NonRel.pol.Mus.raise.supp.unempDF
fig11.cit.Mus.pol.Mus.raise.supp.unempDF <- ggplot(data = cit.Mus.pol.Mus.raise.supp.unempDF, 
                                                  aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig11.cit.Mus.pol.Mus.raise.supp.unempDF
fig11.cit.Mus.pol.NonRel.raise.supp.unempDF <- ggplot(data = cit.Mus.pol.NonRel.raise.supp.unempDF, 
                                                     aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig11.cit.Mus.pol.NonRel.raise.supp.unempDF

fig11 <- fig11.cit.NonRel.pol.NonRel.raise.supp.unempDF/fig11.cit.NonRel.pol.Mus.raise.supp.unempDF/fig11.cit.Mus.pol.Mus.raise.supp.unempDF/fig11.cit.Mus.pol.NonRel.raise.supp.unempDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on 
supporting the unemployed?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. Weighted on gender, education, region and urbanization.") 
fig11

#--------------------------------------------#
#--- cross pressured on more.com.climcha? ---#
#--------------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")

#more.com.climcha
#mm
cit.NonRel.pol.NonRel.more.com.climcha <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.more.com.climcha,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.more.com.climcha <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.more.com.climcha,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.Mus.pol.Mus.more.com.climcha <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.more.com.climcha,
                                       id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.more.com.climcha <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.more.com.climcha,
                                          id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.more.com.climchaDF <- data.frame(
  names=cit.NonRel.pol.NonRel.more.com.climcha$level,
  estimate=cit.NonRel.pol.NonRel.more.com.climcha$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.more.com.climcha$lower*100,
  conf.high=cit.NonRel.pol.NonRel.more.com.climcha$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.more.com.climchaDF <- data.frame(
  names=cit.NonRel.pol.Mus.more.com.climcha$level,
  estimate=cit.NonRel.pol.Mus.more.com.climcha$estimate*100,
  conf.low=cit.NonRel.pol.Mus.more.com.climcha$lower*100,
  conf.high=cit.NonRel.pol.Mus.more.com.climcha$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.Mus.more.com.climchaDF <- data.frame(
  names=cit.Mus.pol.Mus.more.com.climcha$level,
  estimate=cit.Mus.pol.Mus.more.com.climcha$estimate*100,
  conf.low=cit.Mus.pol.Mus.more.com.climcha$lower*100,
  conf.high=cit.Mus.pol.Mus.more.com.climcha$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.NonRel.more.com.climchaDF <- data.frame(
  names=cit.Mus.pol.NonRel.more.com.climcha$level,
  estimate=cit.Mus.pol.NonRel.more.com.climcha$estimate*100,
  conf.low=cit.Mus.pol.NonRel.more.com.climcha$lower*100,
  conf.high=cit.Mus.pol.NonRel.more.com.climcha$upper*100,  number=c("001", "002", "003", "004"))

#ggplot
fig12.cit.NonRel.pol.NonRel.more.com.climchaDF <- ggplot(data = cit.NonRel.pol.NonRel.more.com.climchaDF, 
                                                        aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig12.cit.NonRel.pol.NonRel.more.com.climchaDF
fig12.cit.NonRel.pol.Mus.more.com.climchaDF <- ggplot(data = cit.NonRel.pol.Mus.more.com.climchaDF, 
                                                     aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig12.cit.NonRel.pol.Mus.more.com.climchaDF
fig12.cit.Mus.pol.Mus.more.com.climchaDF <- ggplot(data = cit.Mus.pol.Mus.more.com.climchaDF, 
                                                  aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig12.cit.Mus.pol.Mus.more.com.climchaDF
fig12.cit.Mus.pol.NonRel.more.com.climchaDF <- ggplot(data = cit.Mus.pol.NonRel.more.com.climchaDF, 
                                                     aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig12.cit.Mus.pol.NonRel.more.com.climchaDF

fig12 <- fig12.cit.NonRel.pol.NonRel.more.com.climchaDF/fig12.cit.NonRel.pol.Mus.more.com.climchaDF/fig12.cit.Mus.pol.Mus.more.com.climchaDF/fig12.cit.Mus.pol.NonRel.more.com.climchaDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on 
combatting climate change?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. Weighted on gender, education, region and urbanization.") 
fig12

#--------------------------------------------#
#--- cross pressured on raise.fuel.price? ---#
#--------------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")

#raise.fuel.price
#mm
cit.NonRel.pol.NonRel.raise.fuel.price <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.raise.fuel.price,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.raise.fuel.price <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.raise.fuel.price,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.Mus.pol.Mus.raise.fuel.price <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.raise.fuel.price,
                                       id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.raise.fuel.price <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.raise.fuel.price,
                                          id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.raise.fuel.priceDF <- data.frame(
  names=cit.NonRel.pol.NonRel.raise.fuel.price$level,
  estimate=cit.NonRel.pol.NonRel.raise.fuel.price$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.raise.fuel.price$lower*100,
  conf.high=cit.NonRel.pol.NonRel.raise.fuel.price$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.raise.fuel.priceDF <- data.frame(
  names=cit.NonRel.pol.Mus.raise.fuel.price$level,
  estimate=cit.NonRel.pol.Mus.raise.fuel.price$estimate*100,
  conf.low=cit.NonRel.pol.Mus.raise.fuel.price$lower*100,
  conf.high=cit.NonRel.pol.Mus.raise.fuel.price$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.Mus.raise.fuel.priceDF <- data.frame(
  names=cit.Mus.pol.Mus.raise.fuel.price$level,
  estimate=cit.Mus.pol.Mus.raise.fuel.price$estimate*100,
  conf.low=cit.Mus.pol.Mus.raise.fuel.price$lower*100,
  conf.high=cit.Mus.pol.Mus.raise.fuel.price$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.NonRel.raise.fuel.priceDF <- data.frame(
  names=cit.Mus.pol.NonRel.raise.fuel.price$level,
  estimate=cit.Mus.pol.NonRel.raise.fuel.price$estimate*100,
  conf.low=cit.Mus.pol.NonRel.raise.fuel.price$lower*100,
  conf.high=cit.Mus.pol.NonRel.raise.fuel.price$upper*100,  number=c("001", "002", "003", "004"))

#ggplot
fig13.cit.NonRel.pol.NonRel.raise.fuel.priceDF <- ggplot(data = cit.NonRel.pol.NonRel.raise.fuel.priceDF, 
                                                        aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig13.cit.NonRel.pol.NonRel.raise.fuel.priceDF
fig13.cit.NonRel.pol.Mus.raise.fuel.priceDF <- ggplot(data = cit.NonRel.pol.Mus.raise.fuel.priceDF, 
                                                     aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig13.cit.NonRel.pol.Mus.raise.fuel.priceDF
fig13.cit.Mus.pol.Mus.raise.fuel.priceDF <- ggplot(data = cit.Mus.pol.Mus.raise.fuel.priceDF, 
                                                  aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig13.cit.Mus.pol.Mus.raise.fuel.priceDF
fig13.cit.Mus.pol.NonRel.raise.fuel.priceDF <- ggplot(data = cit.Mus.pol.NonRel.raise.fuel.priceDF, 
                                                     aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig13.cit.Mus.pol.NonRel.raise.fuel.priceDF

fig13 <- fig13.cit.NonRel.pol.NonRel.raise.fuel.priceDF/fig13.cit.NonRel.pol.Mus.raise.fuel.priceDF/fig13.cit.Mus.pol.Mus.raise.fuel.priceDF/fig13.cit.Mus.pol.NonRel.raise.fuel.priceDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on 
raising the fuel price?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. Weighted on gender, education, region and urbanization.") 
fig13

#--------------------------------------------#
#--- cross pressured on immigrants.R.asset? ---#
#--------------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")

#immigrants.R.asset
#mm
cit.NonRel.pol.NonRel.immigrants.R.asset <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.immigrants.R.asset,
                                               id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.immigrants.R.asset <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.immigrants.R.asset,
                                            id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.Mus.pol.Mus.immigrants.R.asset <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.immigrants.R.asset,
                                         id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.immigrants.R.asset <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.immigrants.R.asset,
                                            id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.immigrants.R.assetDF <- data.frame(
  names=cit.NonRel.pol.NonRel.immigrants.R.asset$level,
  estimate=cit.NonRel.pol.NonRel.immigrants.R.asset$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.immigrants.R.asset$lower*100,
  conf.high=cit.NonRel.pol.NonRel.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.immigrants.R.assetDF <- data.frame(
  names=cit.NonRel.pol.Mus.immigrants.R.asset$level,
  estimate=cit.NonRel.pol.Mus.immigrants.R.asset$estimate*100,
  conf.low=cit.NonRel.pol.Mus.immigrants.R.asset$lower*100,
  conf.high=cit.NonRel.pol.Mus.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.Mus.immigrants.R.assetDF <- data.frame(
  names=cit.Mus.pol.Mus.immigrants.R.asset$level,
  estimate=cit.Mus.pol.Mus.immigrants.R.asset$estimate*100,
  conf.low=cit.Mus.pol.Mus.immigrants.R.asset$lower*100,
  conf.high=cit.Mus.pol.Mus.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.NonRel.immigrants.R.assetDF <- data.frame(
  names=cit.Mus.pol.NonRel.immigrants.R.asset$level,
  estimate=cit.Mus.pol.NonRel.immigrants.R.asset$estimate*100,
  conf.low=cit.Mus.pol.NonRel.immigrants.R.asset$lower*100,
  conf.high=cit.Mus.pol.NonRel.immigrants.R.asset$upper*100,  number=c("001", "002", "003", "004"))

#ggplot
fig14.cit.NonRel.pol.NonRel.immigrants.R.assetDF <- ggplot(data = cit.NonRel.pol.NonRel.immigrants.R.assetDF, 
                                                          aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig14.cit.NonRel.pol.NonRel.immigrants.R.assetDF
fig14.cit.NonRel.pol.Mus.immigrants.R.assetDF <- ggplot(data = cit.NonRel.pol.Mus.immigrants.R.assetDF, 
                                                       aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig14.cit.NonRel.pol.Mus.immigrants.R.assetDF
fig14.cit.Mus.pol.Mus.immigrants.R.assetDF <- ggplot(data = cit.Mus.pol.Mus.immigrants.R.assetDF, 
                                                    aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig14.cit.Mus.pol.Mus.immigrants.R.assetDF

fig14.cit.Mus.pol.NonRel.immigrants.R.assetDF <- ggplot(data = cit.Mus.pol.NonRel.immigrants.R.assetDF, 
                                                       aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig14.cit.Mus.pol.NonRel.immigrants.R.assetDF

fig14 <- fig14.cit.NonRel.pol.NonRel.immigrants.R.assetDF/fig14.cit.NonRel.pol.Mus.immigrants.R.assetDF/fig14.cit.Mus.pol.Mus.immigrants.R.assetDF/fig14.cit.Mus.pol.NonRel.immigrants.R.assetDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on 
whether immigrants are an asset to society?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. Weighted on gender, education, region and urbanization.") 
fig14

#--------------------------------------------#
#--- cross pressured on islam.not.restricted? ---#
#--------------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")

#islam.not.restricted
#mm
cit.NonRel.pol.NonRel.islam.not.restricted <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.islam.not.restricted,
                                                 id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.islam.not.restricted <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.islam.not.restricted,
                                              id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.Mus.pol.Mus.islam.not.restricted <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.islam.not.restricted,
                                           id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.islam.not.restricted <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.islam.not.restricted,
                                              id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.islam.not.restrictedDF <- data.frame(
  names=cit.NonRel.pol.NonRel.islam.not.restricted$level,
  estimate=cit.NonRel.pol.NonRel.islam.not.restricted$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.islam.not.restricted$lower*100,
  conf.high=cit.NonRel.pol.NonRel.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.islam.not.restrictedDF <- data.frame(
  names=cit.NonRel.pol.Mus.islam.not.restricted$level,
  estimate=cit.NonRel.pol.Mus.islam.not.restricted$estimate*100,
  conf.low=cit.NonRel.pol.Mus.islam.not.restricted$lower*100,
  conf.high=cit.NonRel.pol.Mus.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.Mus.islam.not.restrictedDF <- data.frame(
  names=cit.Mus.pol.Mus.islam.not.restricted$level,
  estimate=cit.Mus.pol.Mus.islam.not.restricted$estimate*100,
  conf.low=cit.Mus.pol.Mus.islam.not.restricted$lower*100,
  conf.high=cit.Mus.pol.Mus.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.NonRel.islam.not.restrictedDF <- data.frame(
  names=cit.Mus.pol.NonRel.islam.not.restricted$level,
  estimate=cit.Mus.pol.NonRel.islam.not.restricted$estimate*100,
  conf.low=cit.Mus.pol.NonRel.islam.not.restricted$lower*100,
  conf.high=cit.Mus.pol.NonRel.islam.not.restricted$upper*100,  number=c("001", "002", "003", "004"))

#ggplot
fig15.cit.NonRel.pol.NonRel.islam.not.restrictedDF <- ggplot(data = cit.NonRel.pol.NonRel.islam.not.restrictedDF, 
                                                            aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig15.cit.NonRel.pol.NonRel.islam.not.restrictedDF
fig15.cit.NonRel.pol.Mus.islam.not.restrictedDF <- ggplot(data = cit.NonRel.pol.Mus.islam.not.restrictedDF, 
                                                         aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig15.cit.NonRel.pol.Mus.islam.not.restrictedDF
fig15.cit.Mus.pol.Mus.islam.not.restrictedDF <- ggplot(data = cit.Mus.pol.Mus.islam.not.restrictedDF, 
                                                      aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig15.cit.Mus.pol.Mus.islam.not.restrictedDF
fig15.cit.Mus.pol.NonRel.islam.not.restrictedDF <- ggplot(data = cit.Mus.pol.NonRel.islam.not.restrictedDF, 
                                                         aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig15.cit.Mus.pol.NonRel.islam.not.restrictedDF

fig15 <- fig15.cit.NonRel.pol.NonRel.islam.not.restrictedDF/fig15.cit.NonRel.pol.Mus.islam.not.restrictedDF/fig15.cit.Mus.pol.Mus.islam.not.restrictedDF/fig15.cit.Mus.pol.NonRel.islam.not.restrictedDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on 
whether Islam should be restricted?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. Weighted on gender, education, region and urbanization.") 
fig15

#-------------------------------------------#
#--- cross pressured on gender equality? ---#
#-------------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")

#equal.pay.by.law
#mm
cit.NonRel.pol.NonRel.equal.pay.by.law <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.equal.pay.by.law <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.Mus.pol.Mus.equal.pay.by.law <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.equal.pay.by.law,
                                       id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.equal.pay.by.law <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.equal.pay.by.law,
                                          id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.NonRel.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.NonRel.pol.Mus.equal.pay.by.law$level,
  estimate=cit.NonRel.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.NonRel.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.NonRel.pol.Mus.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.Mus.equal.pay.by.lawDF <- data.frame(
  names=cit.Mus.pol.Mus.equal.pay.by.law$level,
  estimate=cit.Mus.pol.Mus.equal.pay.by.law$estimate*100,
  conf.low=cit.Mus.pol.Mus.equal.pay.by.law$lower*100,
  conf.high=cit.Mus.pol.Mus.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.NonRel.equal.pay.by.lawDF <- data.frame(
  names=cit.Mus.pol.NonRel.equal.pay.by.law$level,
  estimate=cit.Mus.pol.NonRel.equal.pay.by.law$estimate*100,
  conf.low=cit.Mus.pol.NonRel.equal.pay.by.law$lower*100,
  conf.high=cit.Mus.pol.NonRel.equal.pay.by.law$upper*100,  number=c("001", "002", "003", "004"))

#ggplot
fig5.cit.NonRel.pol.NonRel.equal.pay.by.lawDF <- ggplot(data = cit.NonRel.pol.NonRel.equal.pay.by.lawDF, 
                                                        aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig5.cit.NonRel.pol.NonRel.equal.pay.by.lawDF
fig5.cit.NonRel.pol.Mus.equal.pay.by.lawDF <- ggplot(data = cit.NonRel.pol.Mus.equal.pay.by.lawDF, 
                                                     aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig5.cit.NonRel.pol.Mus.equal.pay.by.lawDF
fig5.cit.Mus.pol.Mus.equal.pay.by.lawDF <- ggplot(data = cit.Mus.pol.Mus.equal.pay.by.lawDF, 
                                                  aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig5.cit.Mus.pol.Mus.equal.pay.by.lawDF
fig5.cit.Mus.pol.NonRel.equal.pay.by.lawDF <- ggplot(data = cit.Mus.pol.NonRel.equal.pay.by.lawDF, 
                                                     aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig5.cit.Mus.pol.NonRel.equal.pay.by.lawDF

fig5 <- fig5.cit.NonRel.pol.NonRel.equal.pay.by.lawDF/fig5.cit.NonRel.pol.Mus.equal.pay.by.lawDF/fig5.cit.Mus.pol.Mus.equal.pay.by.lawDF/fig5.cit.Mus.pol.NonRel.equal.pay.by.lawDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on gender equality?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. Weighted on gender, education, region and urbanization.") 
fig5

#-----------------------------------------#
#--- cross pressured on homosexuality? ---#
#-----------------------------------------#

FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")

#homoco.may.adopt
#mm
cit.NonRel.pol.NonRel.homoco.may.adopt <- mm(FGNcit.NonRel.pol.NonRel, DVcho ~ samepp.homoco.may.adopt,
                                             id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.NonRel.pol.Mus.homoco.may.adopt <- mm(FGNcit.NonRel.pol.Mus, DVcho ~ samepp.homoco.may.adopt,
                                          id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
cit.Mus.pol.Mus.homoco.may.adopt <- mm(FGNcit.Mus.pol.Mus, DVcho ~ samepp.homoco.may.adopt,
                                       id = ~ INTNR, h0 = 0.5)
cit.Mus.pol.NonRel.homoco.may.adopt <- mm(FGNcit.Mus.pol.NonRel, DVcho ~ samepp.homoco.may.adopt,
                                          id = ~ INTNR, h0 = 0.5)

#making df
cit.NonRel.pol.NonRel.homoco.may.adoptDF <- data.frame(
  names=cit.NonRel.pol.NonRel.homoco.may.adopt$level,
  estimate=cit.NonRel.pol.NonRel.homoco.may.adopt$estimate*100,
  conf.low=cit.NonRel.pol.NonRel.homoco.may.adopt$lower*100,
  conf.high=cit.NonRel.pol.NonRel.homoco.may.adopt$upper*100,  number=c("001", "002", "003", "004"))

cit.NonRel.pol.Mus.homoco.may.adoptDF <- data.frame(
  names=cit.NonRel.pol.Mus.homoco.may.adopt$level,
  estimate=cit.NonRel.pol.Mus.homoco.may.adopt$estimate*100,
  conf.low=cit.NonRel.pol.Mus.homoco.may.adopt$lower*100,
  conf.high=cit.NonRel.pol.Mus.homoco.may.adopt$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.Mus.homoco.may.adoptDF <- data.frame(
  names=cit.Mus.pol.Mus.homoco.may.adopt$level,
  estimate=cit.Mus.pol.Mus.homoco.may.adopt$estimate*100,
  conf.low=cit.Mus.pol.Mus.homoco.may.adopt$lower*100,
  conf.high=cit.Mus.pol.Mus.homoco.may.adopt$upper*100,  number=c("001", "002", "003", "004"))

cit.Mus.pol.NonRel.homoco.may.adoptDF <- data.frame(
  names=cit.Mus.pol.NonRel.homoco.may.adopt$level,
  estimate=cit.Mus.pol.NonRel.homoco.may.adopt$estimate*100,
  conf.low=cit.Mus.pol.NonRel.homoco.may.adopt$lower*100,
  conf.high=cit.Mus.pol.NonRel.homoco.may.adopt$upper*100,  number=c("001", "002", "003", "004"))

#ggplot
fig16.cit.NonRel.pol.NonRel.homoco.may.adoptDF <- ggplot(data = cit.NonRel.pol.NonRel.homoco.may.adoptDF, 
                                                        aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig16.cit.NonRel.pol.NonRel.homoco.may.adoptDF
fig16.cit.NonRel.pol.Mus.homoco.may.adoptDF <- ggplot(data = cit.NonRel.pol.Mus.homoco.may.adoptDF, 
                                                     aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Non-religious citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig16.cit.NonRel.pol.Mus.homoco.may.adoptDF
fig16.cit.Mus.pol.Mus.homoco.may.adoptDF <- ggplot(data = cit.Mus.pol.Mus.homoco.may.adoptDF, 
                                                  aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing Muslim politicians") +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig16.cit.Mus.pol.Mus.homoco.may.adoptDF
fig16.cit.Mus.pol.NonRel.homoco.may.adoptDF <- ggplot(data = cit.Mus.pol.NonRel.homoco.may.adoptDF, 
                                                     aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ggtitle("Muslim citizens assessing non-religious politicians") +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 110) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig16.cit.Mus.pol.NonRel.homoco.may.adoptDF

fig16 <- fig16.cit.NonRel.pol.NonRel.homoco.may.adoptDF/fig16.cit.NonRel.pol.Mus.homoco.may.adoptDF/fig16.cit.Mus.pol.Mus.homoco.may.adoptDF/fig16.cit.Mus.pol.NonRel.homoco.may.adoptDF +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same policy position on 
whether homosexual couples should be allowed to adopt children?',
                  subtitle = ' ',
                  caption = "
                  Error bars represent the 95% confidence interval. Respondents answered on a scale from 0 to 10 whether they agreed with the statement, 
                  respondents who answered the middle position 5 were excluded from the analysis. Weighted on gender, education, region and urbanization.") 
fig16

#-----------------------------------#
#--- fig17 level of... agreement ---# 
#-----------------------------------#

#tax.rich.higher
#cit.Nonrel
#cit.NonRel.pol.NonRel
FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
#tax.rich.higher
cit.NonRel.pol.NonRel.subset.tax.rich.higher <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.NonRel, 
  formula = FGNcit.NonRel.pol.NonRel$DVcho ~ 
    FGNcit.NonRel.pol.NonRel$level.of.samepp.tax.rich.higher,
  cluster=FGNcit.NonRel.pol.NonRel$INTNR)
summary(cit.NonRel.pol.NonRel.subset.tax.rich.higher)

#cit.NonRel.pol.Mus
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
#tax.rich.higher
cit.NonRel.pol.Mus.subset.tax.rich.higher <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.Mus, 
  formula = FGNcit.NonRel.pol.Mus$DVcho ~ 
    FGNcit.NonRel.pol.Mus$level.of.samepp.tax.rich.higher,
  cluster=FGNcit.NonRel.pol.Mus$INTNR)
summary(cit.NonRel.pol.Mus.subset.tax.rich.higher)

#cit.Mus
#cit.Mus.pol.Mus
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
#tax.rich.higher
cit.Mus.pol.Mus.subset.tax.rich.higher <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.Mus, 
  formula = FGNcit.Mus.pol.Mus$DVcho ~ 
    FGNcit.Mus.pol.Mus$level.of.samepp.tax.rich.higher,
  cluster=FGNcit.Mus.pol.Mus$INTNR)
summary(cit.Mus.pol.Mus.subset.tax.rich.higher)

#cit.Mus.pol.NonRel
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")
#tax.rich.higher
cit.Mus.pol.NonRel.subset.tax.rich.higher <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.NonRel, 
  formula = FGNcit.Mus.pol.NonRel$DVcho ~ 
    FGNcit.Mus.pol.NonRel$level.of.samepp.tax.rich.higher,
  cluster=FGNcit.Mus.pol.NonRel$INTNR)
summary(cit.Mus.pol.NonRel.subset.tax.rich.higher)

#raise.supp.unemp
#cit.Nonrel
#cit.NonRel.pol.NonRel
FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
#raise.supp.unemp
cit.NonRel.pol.NonRel.subset.raise.supp.unemp <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.NonRel, 
  formula = FGNcit.NonRel.pol.NonRel$DVcho ~ 
    FGNcit.NonRel.pol.NonRel$level.of.samepp.raise.supp.unemp,
  cluster=FGNcit.NonRel.pol.NonRel$INTNR)
summary(cit.NonRel.pol.NonRel.subset.raise.supp.unemp)

#cit.NonRel.pol.Mus
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
#raise.supp.unemp
cit.NonRel.pol.Mus.subset.raise.supp.unemp <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.Mus, 
  formula = FGNcit.NonRel.pol.Mus$DVcho ~ 
    FGNcit.NonRel.pol.Mus$level.of.samepp.raise.supp.unemp,
  cluster=FGNcit.NonRel.pol.Mus$INTNR)
summary(cit.NonRel.pol.Mus.subset.raise.supp.unemp)

#cit.Mus
#cit.Mus.pol.Mus
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
#raise.supp.unemp
cit.Mus.pol.Mus.subset.raise.supp.unemp <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.Mus, 
  formula = FGNcit.Mus.pol.Mus$DVcho ~ 
    FGNcit.Mus.pol.Mus$level.of.samepp.raise.supp.unemp,
  cluster=FGNcit.Mus.pol.Mus$INTNR)
summary(cit.Mus.pol.Mus.subset.raise.supp.unemp)

#cit.Mus.pol.NonRel
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")
#raise.supp.unemp
cit.Mus.pol.NonRel.subset.raise.supp.unemp <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.NonRel, 
  formula = FGNcit.Mus.pol.NonRel$DVcho ~ 
    FGNcit.Mus.pol.NonRel$level.of.samepp.raise.supp.unemp,
  cluster=FGNcit.Mus.pol.NonRel$INTNR)
summary(cit.Mus.pol.NonRel.subset.raise.supp.unemp)

#more.com.climcha
#cit.Nonrel
#cit.NonRel.pol.NonRel
FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
#more.com.climcha
cit.NonRel.pol.NonRel.subset.more.com.climcha <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.NonRel, 
  formula = FGNcit.NonRel.pol.NonRel$DVcho ~ 
    FGNcit.NonRel.pol.NonRel$level.of.samepp.more.com.climcha,
  cluster=FGNcit.NonRel.pol.NonRel$INTNR)
summary(cit.NonRel.pol.NonRel.subset.more.com.climcha)

#cit.NonRel.pol.Mus
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
#more.com.climcha
cit.NonRel.pol.Mus.subset.more.com.climcha <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.Mus, 
  formula = FGNcit.NonRel.pol.Mus$DVcho ~ 
    FGNcit.NonRel.pol.Mus$level.of.samepp.more.com.climcha,
  cluster=FGNcit.NonRel.pol.Mus$INTNR)
summary(cit.NonRel.pol.Mus.subset.more.com.climcha)

#cit.Mus
#cit.Mus.pol.Mus
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
#more.com.climcha
cit.Mus.pol.Mus.subset.more.com.climcha <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.Mus, 
  formula = FGNcit.Mus.pol.Mus$DVcho ~ 
    FGNcit.Mus.pol.Mus$level.of.samepp.more.com.climcha,
  cluster=FGNcit.Mus.pol.Mus$INTNR)
summary(cit.Mus.pol.Mus.subset.more.com.climcha)

#cit.Mus.pol.NonRel
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")
#more.com.climcha
cit.Mus.pol.NonRel.subset.more.com.climcha <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.NonRel, 
  formula = FGNcit.Mus.pol.NonRel$DVcho ~ 
    FGNcit.Mus.pol.NonRel$level.of.samepp.more.com.climcha,
  cluster=FGNcit.Mus.pol.NonRel$INTNR)
summary(cit.Mus.pol.NonRel.subset.more.com.climcha)

#raise.fuel.price
#cit.Nonrel
#cit.NonRel.pol.NonRel
FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
#raise.fuel.price
cit.NonRel.pol.NonRel.subset.raise.fuel.price <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.NonRel, 
  formula = FGNcit.NonRel.pol.NonRel$DVcho ~ 
    FGNcit.NonRel.pol.NonRel$level.of.samepp.raise.fuel.price,
  cluster=FGNcit.NonRel.pol.NonRel$INTNR)
summary(cit.NonRel.pol.NonRel.subset.raise.fuel.price)

#cit.NonRel.pol.Mus
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
#raise.fuel.price
cit.NonRel.pol.Mus.subset.raise.fuel.price <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.Mus, 
  formula = FGNcit.NonRel.pol.Mus$DVcho ~ 
    FGNcit.NonRel.pol.Mus$level.of.samepp.raise.fuel.price,
  cluster=FGNcit.NonRel.pol.Mus$INTNR)
summary(cit.NonRel.pol.Mus.subset.raise.fuel.price)

#cit.Mus
#cit.Mus.pol.Mus
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
#raise.fuel.price
cit.Mus.pol.Mus.subset.raise.fuel.price <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.Mus, 
  formula = FGNcit.Mus.pol.Mus$DVcho ~ 
    FGNcit.Mus.pol.Mus$level.of.samepp.raise.fuel.price,
  cluster=FGNcit.Mus.pol.Mus$INTNR)
summary(cit.Mus.pol.Mus.subset.raise.fuel.price)

#cit.Mus.pol.NonRel
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")
#raise.fuel.price
cit.Mus.pol.NonRel.subset.raise.fuel.price <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.NonRel, 
  formula = FGNcit.Mus.pol.NonRel$DVcho ~ 
    FGNcit.Mus.pol.NonRel$level.of.samepp.raise.fuel.price,
  cluster=FGNcit.Mus.pol.NonRel$INTNR)
summary(cit.Mus.pol.NonRel.subset.raise.fuel.price)

#immigrants.R.asset
#cit.Nonrel
#cit.NonRel.pol.NonRel
FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
#immigrants.R.asset
cit.NonRel.pol.NonRel.subset.immigrants.R.asset <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.NonRel, 
  formula = FGNcit.NonRel.pol.NonRel$DVcho ~ 
    FGNcit.NonRel.pol.NonRel$level.of.samepp.immigrants.R.asset,
  cluster=FGNcit.NonRel.pol.NonRel$INTNR)
summary(cit.NonRel.pol.NonRel.subset.immigrants.R.asset)

#cit.NonRel.pol.Mus
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
#immigrants.R.asset
cit.NonRel.pol.Mus.subset.immigrants.R.asset <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.Mus, 
  formula = FGNcit.NonRel.pol.Mus$DVcho ~ 
    FGNcit.NonRel.pol.Mus$level.of.samepp.immigrants.R.asset,
  cluster=FGNcit.NonRel.pol.Mus$INTNR)
summary(cit.NonRel.pol.Mus.subset.immigrants.R.asset)

#cit.Mus
#cit.Mus.pol.Mus
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
#immigrants.R.asset
cit.Mus.pol.Mus.subset.immigrants.R.asset <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.Mus, 
  formula = FGNcit.Mus.pol.Mus$DVcho ~ 
    FGNcit.Mus.pol.Mus$level.of.samepp.immigrants.R.asset,
  cluster=FGNcit.Mus.pol.Mus$INTNR)
summary(cit.Mus.pol.Mus.subset.immigrants.R.asset)

#cit.Mus.pol.NonRel
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")
#immigrants.R.asset
cit.Mus.pol.NonRel.subset.immigrants.R.asset <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.NonRel, 
  formula = FGNcit.Mus.pol.NonRel$DVcho ~ 
    FGNcit.Mus.pol.NonRel$level.of.samepp.immigrants.R.asset,
  cluster=FGNcit.Mus.pol.NonRel$INTNR)
summary(cit.Mus.pol.NonRel.subset.immigrants.R.asset)

#islam.not.restricted
#cit.Nonrel
#cit.NonRel.pol.NonRel
FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
#islam.not.restricted
cit.NonRel.pol.NonRel.subset.islam.not.restricted <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.NonRel, 
  formula = FGNcit.NonRel.pol.NonRel$DVcho ~ 
    FGNcit.NonRel.pol.NonRel$level.of.samepp.islam.not.restricted,
  cluster=FGNcit.NonRel.pol.NonRel$INTNR)
summary(cit.NonRel.pol.NonRel.subset.islam.not.restricted)

#cit.NonRel.pol.Mus
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
#islam.not.restricted
cit.NonRel.pol.Mus.subset.islam.not.restricted <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.Mus, 
  formula = FGNcit.NonRel.pol.Mus$DVcho ~ 
    FGNcit.NonRel.pol.Mus$level.of.samepp.islam.not.restricted,
  cluster=FGNcit.NonRel.pol.Mus$INTNR)
summary(cit.NonRel.pol.Mus.subset.islam.not.restricted)

#cit.Mus
#cit.Mus.pol.Mus
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
#islam.not.restricted
cit.Mus.pol.Mus.subset.islam.not.restricted <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.Mus, 
  formula = FGNcit.Mus.pol.Mus$DVcho ~ 
    FGNcit.Mus.pol.Mus$level.of.samepp.islam.not.restricted,
  cluster=FGNcit.Mus.pol.Mus$INTNR)
summary(cit.Mus.pol.Mus.subset.islam.not.restricted)

#cit.Mus.pol.NonRel
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")
#islam.not.restricted
cit.Mus.pol.NonRel.subset.islam.not.restricted <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.NonRel, 
  formula = FGNcit.Mus.pol.NonRel$DVcho ~ 
    FGNcit.Mus.pol.NonRel$level.of.samepp.islam.not.restricted,
  cluster=FGNcit.Mus.pol.NonRel$INTNR)
summary(cit.Mus.pol.NonRel.subset.islam.not.restricted)

#equal.pay.by.law
#cit.Nonrel
#cit.NonRel.pol.NonRel
FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
#equal.pay.by.law
cit.NonRel.pol.NonRel.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.NonRel, 
  formula = FGNcit.NonRel.pol.NonRel$DVcho ~ 
    FGNcit.NonRel.pol.NonRel$level.of.samepp.equal.pay.by.law,
  cluster=FGNcit.NonRel.pol.NonRel$INTNR)
summary(cit.NonRel.pol.NonRel.subset.equal.pay.by.law)

#cit.NonRel.pol.Mus
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
#equal.pay.by.law
cit.NonRel.pol.Mus.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.Mus, 
  formula = FGNcit.NonRel.pol.Mus$DVcho ~ 
    FGNcit.NonRel.pol.Mus$level.of.samepp.equal.pay.by.law,
  cluster=FGNcit.NonRel.pol.Mus$INTNR)
summary(cit.NonRel.pol.Mus.subset.equal.pay.by.law)

#cit.Mus
#cit.Mus.pol.Mus
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
#equal.pay.by.law
cit.Mus.pol.Mus.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.Mus, 
  formula = FGNcit.Mus.pol.Mus$DVcho ~ 
    FGNcit.Mus.pol.Mus$level.of.samepp.equal.pay.by.law,
  cluster=FGNcit.Mus.pol.Mus$INTNR)
summary(cit.Mus.pol.Mus.subset.equal.pay.by.law)

#cit.Mus.pol.NonRel
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")
#equal.pay.by.law
cit.Mus.pol.NonRel.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.NonRel, 
  formula = FGNcit.Mus.pol.NonRel$DVcho ~ 
    FGNcit.Mus.pol.NonRel$level.of.samepp.equal.pay.by.law,
  cluster=FGNcit.Mus.pol.NonRel$INTNR)
summary(cit.Mus.pol.NonRel.subset.equal.pay.by.law)

#homoco.may.adopt
#cit.Nonrel
#cit.NonRel.pol.NonRel
FGNcit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
#homoco.may.adopt
cit.NonRel.pol.NonRel.subset.homoco.may.adopt <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.NonRel, 
  formula = FGNcit.NonRel.pol.NonRel$DVcho ~ 
    FGNcit.NonRel.pol.NonRel$level.of.samepp.homoco.may.adopt,
  cluster=FGNcit.NonRel.pol.NonRel$INTNR)
summary(cit.NonRel.pol.NonRel.subset.homoco.may.adopt)

#cit.NonRel.pol.Mus
FGNcit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
#homoco.may.adopt
cit.NonRel.pol.Mus.subset.homoco.may.adopt <- miceadds::lm.cluster(
  data=FGNcit.NonRel.pol.Mus, 
  formula = FGNcit.NonRel.pol.Mus$DVcho ~ 
    FGNcit.NonRel.pol.Mus$level.of.samepp.homoco.may.adopt,
  cluster=FGNcit.NonRel.pol.Mus$INTNR)
summary(cit.NonRel.pol.Mus.subset.homoco.may.adopt)

#cit.Mus
#cit.Mus.pol.Mus
FGNcit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
#homoco.may.adopt
cit.Mus.pol.Mus.subset.homoco.may.adopt <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.Mus, 
  formula = FGNcit.Mus.pol.Mus$DVcho ~ 
    FGNcit.Mus.pol.Mus$level.of.samepp.homoco.may.adopt,
  cluster=FGNcit.Mus.pol.Mus$INTNR)
summary(cit.Mus.pol.Mus.subset.homoco.may.adopt)

#cit.Mus.pol.NonRel
FGNcit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")
#homoco.may.adopt
cit.Mus.pol.NonRel.subset.homoco.may.adopt <- miceadds::lm.cluster(
  data=FGNcit.Mus.pol.NonRel, 
  formula = FGNcit.Mus.pol.NonRel$DVcho ~ 
    FGNcit.Mus.pol.NonRel$level.of.samepp.homoco.may.adopt,
  cluster=FGNcit.Mus.pol.NonRel$INTNR)
summary(cit.Mus.pol.NonRel.subset.homoco.may.adopt)

#as tibble
cit.NonRel.pol.NonRel.subset.tax.rich.higher.tib <- as_tibble(summary(cit.NonRel.pol.NonRel.subset.tax.rich.higher))
cit.NonRel.pol.Mus.subset.tax.rich.higher.tib <- as_tibble(summary(cit.NonRel.pol.Mus.subset.tax.rich.higher))
cit.Mus.pol.Mus.subset.tax.rich.higher.tib <- as_tibble(summary(cit.Mus.pol.Mus.subset.tax.rich.higher))
cit.Mus.pol.NonRel.subset.tax.rich.higher.tib <- as_tibble(summary(cit.Mus.pol.NonRel.subset.tax.rich.higher))
cit.NonRel.pol.NonRel.subset.raise.supp.unemp.tib <- as_tibble(summary(cit.NonRel.pol.NonRel.subset.raise.supp.unemp))
cit.NonRel.pol.Mus.subset.raise.supp.unemp.tib <- as_tibble(summary(cit.NonRel.pol.Mus.subset.raise.supp.unemp))
cit.Mus.pol.Mus.subset.raise.supp.unemp.tib <- as_tibble(summary(cit.Mus.pol.Mus.subset.raise.supp.unemp))
cit.Mus.pol.NonRel.subset.raise.supp.unemp.tib <- as_tibble(summary(cit.Mus.pol.NonRel.subset.raise.supp.unemp))
cit.NonRel.pol.NonRel.subset.more.com.climcha.tib <- as_tibble(summary(cit.NonRel.pol.NonRel.subset.more.com.climcha))
cit.NonRel.pol.Mus.subset.more.com.climcha.tib <- as_tibble(summary(cit.NonRel.pol.Mus.subset.more.com.climcha))
cit.Mus.pol.Mus.subset.more.com.climcha.tib <- as_tibble(summary(cit.Mus.pol.Mus.subset.more.com.climcha))
cit.Mus.pol.NonRel.subset.more.com.climcha.tib <- as_tibble(summary(cit.Mus.pol.NonRel.subset.more.com.climcha))
cit.NonRel.pol.NonRel.subset.raise.fuel.price.tib <- as_tibble(summary(cit.NonRel.pol.NonRel.subset.raise.fuel.price))
cit.NonRel.pol.Mus.subset.raise.fuel.price.tib <- as_tibble(summary(cit.NonRel.pol.Mus.subset.raise.fuel.price))
cit.Mus.pol.Mus.subset.raise.fuel.price.tib <- as_tibble(summary(cit.Mus.pol.Mus.subset.raise.fuel.price))
cit.Mus.pol.NonRel.subset.raise.fuel.price.tib <- as_tibble(summary(cit.Mus.pol.NonRel.subset.raise.fuel.price))
cit.NonRel.pol.NonRel.subset.immigrants.R.asset.tib <- as_tibble(summary(cit.NonRel.pol.NonRel.subset.immigrants.R.asset))
cit.NonRel.pol.Mus.subset.immigrants.R.asset.tib <- as_tibble(summary(cit.NonRel.pol.Mus.subset.immigrants.R.asset))
cit.Mus.pol.Mus.subset.immigrants.R.asset.tib <- as_tibble(summary(cit.Mus.pol.Mus.subset.immigrants.R.asset))
cit.Mus.pol.NonRel.subset.immigrants.R.asset.tib <- as_tibble(summary(cit.Mus.pol.NonRel.subset.immigrants.R.asset))
cit.NonRel.pol.NonRel.subset.islam.not.restricted.tib <- as_tibble(summary(cit.NonRel.pol.NonRel.subset.islam.not.restricted))
cit.NonRel.pol.Mus.subset.islam.not.restricted.tib <- as_tibble(summary(cit.NonRel.pol.Mus.subset.islam.not.restricted))
cit.Mus.pol.Mus.subset.islam.not.restricted.tib <- as_tibble(summary(cit.Mus.pol.Mus.subset.islam.not.restricted))
cit.Mus.pol.NonRel.subset.islam.not.restricted.tib <- as_tibble(summary(cit.Mus.pol.NonRel.subset.islam.not.restricted))
cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib <- as_tibble(summary(cit.NonRel.pol.NonRel.subset.equal.pay.by.law))
cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib <- as_tibble(summary(cit.NonRel.pol.Mus.subset.equal.pay.by.law))
cit.Mus.pol.Mus.subset.equal.pay.by.law.tib <- as_tibble(summary(cit.Mus.pol.Mus.subset.equal.pay.by.law))
cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib <- as_tibble(summary(cit.Mus.pol.NonRel.subset.equal.pay.by.law))
cit.NonRel.pol.NonRel.subset.homoco.may.adopt.tib <- as_tibble(summary(cit.NonRel.pol.NonRel.subset.homoco.may.adopt))
cit.NonRel.pol.Mus.subset.homoco.may.adopt.tib <- as_tibble(summary(cit.NonRel.pol.Mus.subset.homoco.may.adopt))
cit.Mus.pol.Mus.subset.homoco.may.adopt.tib <- as_tibble(summary(cit.Mus.pol.Mus.subset.homoco.may.adopt))
cit.Mus.pol.NonRel.subset.homoco.may.adopt.tib <- as_tibble(summary(cit.Mus.pol.NonRel.subset.homoco.may.adopt))

#removing intercept
cit.NonRel.pol.NonRel.subset.tax.rich.higher.tib <- cit.NonRel.pol.NonRel.subset.tax.rich.higher.tib[-1, ] #remove the intercept
cit.NonRel.pol.Mus.subset.tax.rich.higher.tib <- cit.NonRel.pol.Mus.subset.tax.rich.higher.tib[-1, ] #remove the intercept
cit.Mus.pol.Mus.subset.tax.rich.higher.tib <- cit.Mus.pol.Mus.subset.tax.rich.higher.tib[-1, ] #remove the intercept
cit.Mus.pol.NonRel.subset.tax.rich.higher.tib <- cit.Mus.pol.NonRel.subset.tax.rich.higher.tib[-1, ] #remove the intercept
cit.NonRel.pol.NonRel.subset.raise.supp.unemp.tib <- cit.NonRel.pol.NonRel.subset.raise.supp.unemp.tib[-1, ] #remove the intercept
cit.NonRel.pol.Mus.subset.raise.supp.unemp.tib <- cit.NonRel.pol.Mus.subset.raise.supp.unemp.tib[-1, ] #remove the intercept
cit.Mus.pol.Mus.subset.raise.supp.unemp.tib <- cit.Mus.pol.Mus.subset.raise.supp.unemp.tib[-1, ] #remove the intercept
cit.Mus.pol.NonRel.subset.raise.supp.unemp.tib <- cit.Mus.pol.NonRel.subset.raise.supp.unemp.tib[-1, ] #remove the intercept
cit.NonRel.pol.NonRel.subset.more.com.climcha.tib <- cit.NonRel.pol.NonRel.subset.more.com.climcha.tib[-1, ] #remove the intercept
cit.NonRel.pol.Mus.subset.more.com.climcha.tib <- cit.NonRel.pol.Mus.subset.more.com.climcha.tib[-1, ] #remove the intercept
cit.Mus.pol.Mus.subset.more.com.climcha.tib <- cit.Mus.pol.Mus.subset.more.com.climcha.tib[-1, ] #remove the intercept
cit.Mus.pol.NonRel.subset.more.com.climcha.tib <- cit.Mus.pol.NonRel.subset.more.com.climcha.tib[-1, ] #remove the intercept
cit.NonRel.pol.NonRel.subset.raise.fuel.price.tib <- cit.NonRel.pol.NonRel.subset.raise.fuel.price.tib[-1, ] #remove the intercept
cit.NonRel.pol.Mus.subset.raise.fuel.price.tib <- cit.NonRel.pol.Mus.subset.raise.fuel.price.tib[-1, ] #remove the intercept
cit.Mus.pol.Mus.subset.raise.fuel.price.tib <- cit.Mus.pol.Mus.subset.raise.fuel.price.tib[-1, ] #remove the intercept
cit.Mus.pol.NonRel.subset.raise.fuel.price.tib <- cit.Mus.pol.NonRel.subset.raise.fuel.price.tib[-1, ] #remove the intercept
cit.NonRel.pol.NonRel.subset.immigrants.R.asset.tib <- cit.NonRel.pol.NonRel.subset.immigrants.R.asset.tib[-1, ] #remove the intercept
cit.NonRel.pol.Mus.subset.immigrants.R.asset.tib <- cit.NonRel.pol.Mus.subset.immigrants.R.asset.tib[-1, ] #remove the intercept
cit.Mus.pol.Mus.subset.immigrants.R.asset.tib <- cit.Mus.pol.Mus.subset.immigrants.R.asset.tib[-1, ] #remove the intercept
cit.Mus.pol.NonRel.subset.immigrants.R.asset.tib <- cit.Mus.pol.NonRel.subset.immigrants.R.asset.tib[-1, ] #remove the intercept
cit.NonRel.pol.NonRel.subset.islam.not.restricted.tib <- cit.NonRel.pol.NonRel.subset.islam.not.restricted.tib[-1, ] #remove the intercept
cit.NonRel.pol.Mus.subset.islam.not.restricted.tib <- cit.NonRel.pol.Mus.subset.islam.not.restricted.tib[-1, ] #remove the intercept
cit.Mus.pol.Mus.subset.islam.not.restricted.tib <- cit.Mus.pol.Mus.subset.islam.not.restricted.tib[-1, ] #remove the intercept
cit.Mus.pol.NonRel.subset.islam.not.restricted.tib <- cit.Mus.pol.NonRel.subset.islam.not.restricted.tib[-1, ] #remove the intercept
cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib <- cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib[-1, ] #remove the intercept
cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib <- cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib[-1, ] #remove the intercept
cit.Mus.pol.Mus.subset.equal.pay.by.law.tib <- cit.Mus.pol.Mus.subset.equal.pay.by.law.tib[-1, ] #remove the intercept
cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib <- cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib[-1, ] #remove the intercept
cit.NonRel.pol.NonRel.subset.homoco.may.adopt.tib <- cit.NonRel.pol.NonRel.subset.homoco.may.adopt.tib[-1, ] #remove the intercept
cit.NonRel.pol.Mus.subset.homoco.may.adopt.tib <- cit.NonRel.pol.Mus.subset.homoco.may.adopt.tib[-1, ] #remove the intercept
cit.Mus.pol.Mus.subset.homoco.may.adopt.tib <- cit.Mus.pol.Mus.subset.homoco.may.adopt.tib[-1, ] #remove the intercept
cit.Mus.pol.NonRel.subset.homoco.may.adopt.tib <- cit.Mus.pol.NonRel.subset.homoco.may.adopt.tib[-1, ] #remove the intercept

cit.NonRel.Mus.pol.NonRel.Mus <- rbind(cit.NonRel.pol.NonRel.subset.tax.rich.higher.tib,
                                       cit.NonRel.pol.Mus.subset.tax.rich.higher.tib,
                                       cit.Mus.pol.Mus.subset.tax.rich.higher.tib,
                                       cit.Mus.pol.NonRel.subset.tax.rich.higher.tib,
                                       cit.NonRel.pol.NonRel.subset.raise.supp.unemp.tib,
                                       cit.NonRel.pol.Mus.subset.raise.supp.unemp.tib,
                                       cit.Mus.pol.Mus.subset.raise.supp.unemp.tib,
                                       cit.Mus.pol.NonRel.subset.raise.supp.unemp.tib,
                                       cit.NonRel.pol.NonRel.subset.more.com.climcha.tib,
                                       cit.NonRel.pol.Mus.subset.more.com.climcha.tib,
                                       cit.Mus.pol.Mus.subset.more.com.climcha.tib,
                                       cit.Mus.pol.NonRel.subset.more.com.climcha.tib,
                                       cit.NonRel.pol.NonRel.subset.raise.fuel.price.tib,
                                       cit.NonRel.pol.Mus.subset.raise.fuel.price.tib,
                                       cit.Mus.pol.Mus.subset.raise.fuel.price.tib,
                                       cit.Mus.pol.NonRel.subset.raise.fuel.price.tib,
                                       cit.NonRel.pol.NonRel.subset.immigrants.R.asset.tib,
                                       cit.NonRel.pol.Mus.subset.immigrants.R.asset.tib,
                                       cit.Mus.pol.Mus.subset.immigrants.R.asset.tib,
                                       cit.Mus.pol.NonRel.subset.immigrants.R.asset.tib,
                                       cit.NonRel.pol.NonRel.subset.islam.not.restricted.tib,
                                       cit.NonRel.pol.Mus.subset.islam.not.restricted.tib,
                                       cit.Mus.pol.Mus.subset.islam.not.restricted.tib,
                                       cit.Mus.pol.NonRel.subset.islam.not.restricted.tib,
                                       cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib,
                                       cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib,
                                       cit.Mus.pol.Mus.subset.equal.pay.by.law.tib,
                                       cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib,
                                       cit.NonRel.pol.NonRel.subset.homoco.may.adopt.tib,
                                       cit.NonRel.pol.Mus.subset.homoco.may.adopt.tib,
                                       cit.Mus.pol.Mus.subset.homoco.may.adopt.tib,
                                       cit.Mus.pol.NonRel.subset.homoco.may.adopt.tib)

cit.NonRel.Mus.pol.NonRel.Mus.df <- data.frame(
  names=c("Taxing the rich, non-religious citizen + non-religious politician", "Taxing the rich, non-religious citizen + Muslim politician", "Taxing the rich, Muslim citizen + Muslim politician", "Taxing the rich, Muslim citizen + non-religious politician",
          "Supporting the unemployed, non-religious citizen + non-religious politician", "Supporting the unemployed, non-religious citizen + Muslim politician", "Supporting the unemployed, Muslim citizen + Muslim politician", "Supporting the unemployed, Muslim citizen + non-religious politician",
          "Combating climate change, non-religious citizen + non-religious politician", "Combating climate change, non-religious citizen + Muslim politician", "Combating climate change, Muslim citizen + Muslim politician", "Combating climate change, Muslim citizen + non-religious politician",
          "Raising fuel prices, non-religious citizen + non-religious politician", "Raising fuel prices, non-religious citizen + Muslim politician", "Raising fuel prices, Muslim citizen + Muslim politician", "Raising fuel prices, Muslim citizen + non-religious politician",
          "Immigrant are an asset, non-religious citizen + non-religious politician", "Immigrant are an asset, non-religious citizen + Muslim politician", "Immigrant are an asset, Muslim citizen + Muslim politician", "Immigrant are an asset, Muslim citizen + non-religious politician",
          "Islam should not be restricted, non-religious citizen + non-religious politician", "Islam should not be restricted, non-religious citizen + Muslim politician", "Islam should not be restricted, Muslim citizen + Muslim politician", "Islam should not be restricted, Muslim citizen + non-religious politician",
          "Equal pay, non-religious citizen + non-religious politician", "Equal pay, non-religious citizen + Muslim politician", "Equal pay, Muslim citizen + Muslim politician", "Equal pay, Muslim citizen + non-religious politician",
          "Homosexuality, non-religious citizen + non-religious politician", "Homosexuality, non-religious citizen + Muslim politician", "Homosexuality, Muslim citizen + Muslim politician", "Homosexuality, Muslim citizen + non-religious politician"),
  estimate=cit.NonRel.Mus.pol.NonRel.Mus$Estimate,
  conf.low=((cit.NonRel.Mus.pol.NonRel.Mus$Estimate)-1.96*cit.NonRel.Mus.pol.NonRel.Mus$`Std. Error`),
  conf.high=((cit.NonRel.Mus.pol.NonRel.Mus$Estimate)+1.96*cit.NonRel.Mus.pol.NonRel.Mus$`Std. Error`),
  number=c("001", "002", "003", "004", "005", "006", "007", "008", "009", "010",
           "011", "012", "013", "014", "015", "016", "017", "018", "019", "020",
           "021", "022", "023", "024", "025", "026", "027", "028", "029", "030",
           "031", "032"))

min(cit.NonRel.Mus.pol.NonRel.Mus.df$conf.low)
max(cit.NonRel.Mus.pol.NonRel.Mus.df$conf.high)

#ggplot
hline1.fig17.cit.NonRel.Mus.pol.NonRel.Mus.df <- data.frame(z = c(0.5,
                                                                 4.5,
                                                                 8.5,
                                                                 12.5,
                                                                 16.5,
                                                                 20.5,
                                                                 24.5,
                                                                 28.5,
                                                                 32.5)) 
hline2.fig17.cit.NonRel.Mus.pol.NonRel.Mus.df <- data.frame(z = c(2.5,
                                                                 6.5,
                                                                 10.5,
                                                                 14.5,
                                                                 18.5,
                                                                 22.5,
                                                                 26.5,
                                                                 30.5)) 

fig17.cit.NonRel.Mus.pol.NonRel.Mus.df <- ggplot(data = cit.NonRel.Mus.pol.NonRel.Mus.df, 
                                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  ggtitle(" ") +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-0.11, .83) +
  geom_vline(xintercept = 0) + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dashed", 
             aes(yintercept = z), 
             hline1.fig17.cit.NonRel.Mus.pol.NonRel.Mus.df) +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline2.fig17.cit.NonRel.Mus.pol.NonRel.Mus.df)
fig17.cit.NonRel.Mus.pol.NonRel.Mus.df

library("patchwork")
fig17 <- fig17.cit.NonRel.Mus.pol.NonRel.Mus.df +
  plot_annotation(title = 'Does the level of agreement with a policy position predict voting for an MP Who Looks Like Me?',
                  subtitle = ' ',
                  caption = "
                  Linear models, clustered at the level of the respondent. Error bars represent the 95% confidence interval. 
                  Weighted on gender, education, region and urbanization.") 
fig17

#-----------------------------------------------------------------------------------#
#--- does it matter whether politicians are in favor or against gender equality? ---#
#-----------------------------------------------------------------------------------#
#equal.pay.by.law
#pol.agree.cit.Nonrel
#pol.agree.cit.NonRel.pol.NonRel
FGNpol.agree.cit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
#equal.pay.by.law
pol.agree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNpol.agree.cit.NonRel.pol.NonRel, 
  formula = FGNpol.agree.cit.NonRel.pol.NonRel$DVcho ~ 
    FGNpol.agree.cit.NonRel.pol.NonRel$pol.agree.level.of.samepp.equal.pay.by.law,
  cluster=FGNpol.agree.cit.NonRel.pol.NonRel$INTNR)
summary(pol.agree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law)

#pol.agree.cit.NonRel.pol.Mus
FGNpol.agree.cit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
#equal.pay.by.law
pol.agree.cit.NonRel.pol.Mus.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNpol.agree.cit.NonRel.pol.Mus, 
  formula = FGNpol.agree.cit.NonRel.pol.Mus$DVcho ~ 
    FGNpol.agree.cit.NonRel.pol.Mus$pol.agree.level.of.samepp.equal.pay.by.law,
  cluster=FGNpol.agree.cit.NonRel.pol.Mus$INTNR)
summary(pol.agree.cit.NonRel.pol.Mus.subset.equal.pay.by.law)

#pol.agree.cit.Mus
#pol.agree.cit.Mus.pol.Mus
FGNpol.agree.cit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
#equal.pay.by.law
pol.agree.cit.Mus.pol.Mus.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNpol.agree.cit.Mus.pol.Mus, 
  formula = FGNpol.agree.cit.Mus.pol.Mus$DVcho ~ 
    FGNpol.agree.cit.Mus.pol.Mus$pol.agree.level.of.samepp.equal.pay.by.law,
  cluster=FGNpol.agree.cit.Mus.pol.Mus$INTNR)
summary(pol.agree.cit.Mus.pol.Mus.subset.equal.pay.by.law)

#pol.agree.cit.Mus.pol.NonRel
FGNpol.agree.cit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")
#equal.pay.by.law
pol.agree.cit.Mus.pol.NonRel.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNpol.agree.cit.Mus.pol.NonRel, 
  formula = FGNpol.agree.cit.Mus.pol.NonRel$DVcho ~ 
    FGNpol.agree.cit.Mus.pol.NonRel$pol.agree.level.of.samepp.equal.pay.by.law,
  cluster=FGNpol.agree.cit.Mus.pol.NonRel$INTNR)
summary(pol.agree.cit.Mus.pol.NonRel.subset.equal.pay.by.law)

#equal.pay.by.law
#pol.disagree.cit.Nonrel
#pol.disagree.cit.NonRel.pol.NonRel
FGNpol.disagree.cit.NonRel.pol.NonRel <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="non-religious politician")
#equal.pay.by.law
pol.disagree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNpol.disagree.cit.NonRel.pol.NonRel, 
  formula = FGNpol.disagree.cit.NonRel.pol.NonRel$DVcho ~ 
    FGNpol.disagree.cit.NonRel.pol.NonRel$pol.disagree.level.of.samepp.equal.pay.by.law,
  cluster=FGNpol.disagree.cit.NonRel.pol.NonRel$INTNR)
summary(pol.disagree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law)

#pol.disagree.cit.NonRel.pol.Mus
FGNpol.disagree.cit.NonRel.pol.Mus <- subset(FGN, binidrel2=="Non-religious" & Politician.Religion=="Muslim politician")
#equal.pay.by.law
pol.disagree.cit.NonRel.pol.Mus.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNpol.disagree.cit.NonRel.pol.Mus, 
  formula = FGNpol.disagree.cit.NonRel.pol.Mus$DVcho ~ 
    FGNpol.disagree.cit.NonRel.pol.Mus$pol.disagree.level.of.samepp.equal.pay.by.law,
  cluster=FGNpol.disagree.cit.NonRel.pol.Mus$INTNR)
summary(pol.disagree.cit.NonRel.pol.Mus.subset.equal.pay.by.law)

#pol.disagree.cit.Mus
#pol.disagree.cit.Mus.pol.Mus
FGNpol.disagree.cit.Mus.pol.Mus <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="Muslim politician")
#equal.pay.by.law
pol.disagree.cit.Mus.pol.Mus.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNpol.disagree.cit.Mus.pol.Mus, 
  formula = FGNpol.disagree.cit.Mus.pol.Mus$DVcho ~ 
    FGNpol.disagree.cit.Mus.pol.Mus$pol.disagree.level.of.samepp.equal.pay.by.law,
  cluster=FGNpol.disagree.cit.Mus.pol.Mus$INTNR)
summary(pol.disagree.cit.Mus.pol.Mus.subset.equal.pay.by.law)

#pol.disagree.cit.Mus.pol.NonRel
FGNpol.disagree.cit.Mus.pol.NonRel <- subset(FGN, binidrel2=="Muslim" & Politician.Religion=="non-religious politician")
#equal.pay.by.law
pol.disagree.cit.Mus.pol.NonRel.subset.equal.pay.by.law <- miceadds::lm.cluster(
  data=FGNpol.disagree.cit.Mus.pol.NonRel, 
  formula = FGNpol.disagree.cit.Mus.pol.NonRel$DVcho ~ 
    FGNpol.disagree.cit.Mus.pol.NonRel$pol.disagree.level.of.samepp.equal.pay.by.law,
  cluster=FGNpol.disagree.cit.Mus.pol.NonRel$INTNR)
summary(pol.disagree.cit.Mus.pol.NonRel.subset.equal.pay.by.law)

#as tibble
pol.agree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib <- as_tibble(summary(pol.agree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law))
pol.agree.cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib <- as_tibble(summary(pol.agree.cit.NonRel.pol.Mus.subset.equal.pay.by.law))
pol.agree.cit.Mus.pol.Mus.subset.equal.pay.by.law.tib <- as_tibble(summary(pol.agree.cit.Mus.pol.Mus.subset.equal.pay.by.law))
pol.agree.cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib <- as_tibble(summary(pol.agree.cit.Mus.pol.NonRel.subset.equal.pay.by.law))

pol.disagree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib <- as_tibble(summary(pol.disagree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law))
pol.disagree.cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib <- as_tibble(summary(pol.disagree.cit.NonRel.pol.Mus.subset.equal.pay.by.law))
pol.disagree.cit.Mus.pol.Mus.subset.equal.pay.by.law.tib <- as_tibble(summary(pol.disagree.cit.Mus.pol.Mus.subset.equal.pay.by.law))
pol.disagree.cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib <- as_tibble(summary(pol.disagree.cit.Mus.pol.NonRel.subset.equal.pay.by.law))

#removing intercept
pol.agree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib <- pol.agree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib[-1, ] #remove the intercept
pol.agree.cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib <- pol.agree.cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib[-1, ] #remove the intercept
pol.agree.cit.Mus.pol.Mus.subset.equal.pay.by.law.tib <- pol.agree.cit.Mus.pol.Mus.subset.equal.pay.by.law.tib[-1, ] #remove the intercept
pol.agree.cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib <- pol.agree.cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib[-1, ] #remove the intercept

pol.disagree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib <- pol.disagree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib[-1, ] #remove the intercept
pol.disagree.cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib <- pol.disagree.cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib[-1, ] #remove the intercept
pol.disagree.cit.Mus.pol.Mus.subset.equal.pay.by.law.tib <- pol.disagree.cit.Mus.pol.Mus.subset.equal.pay.by.law.tib[-1, ] #remove the intercept
pol.disagree.cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib <- pol.disagree.cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib[-1, ] #remove the intercept

cit.NonRel.Mus.pol.NonRel.Mus <- rbind(
  pol.agree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib,
  pol.agree.cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib,
  pol.agree.cit.Mus.pol.Mus.subset.equal.pay.by.law.tib,
  pol.agree.cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib,
  
  pol.disagree.cit.NonRel.pol.NonRel.subset.equal.pay.by.law.tib,
  pol.disagree.cit.NonRel.pol.Mus.subset.equal.pay.by.law.tib,
  pol.disagree.cit.Mus.pol.Mus.subset.equal.pay.by.law.tib,
  pol.disagree.cit.Mus.pol.NonRel.subset.equal.pay.by.law.tib)

cit.NonRel.Mus.pol.NonRel.Mus.df <- data.frame(
  names=c("Politician agrees, non-religious citizen + non-religious politician", "Politician agrees, non-religious citizen + Muslim politician", "Politician agrees, Muslim citizen + Muslim politician", "Politician agrees, Muslim citizen + non-religious politician",
          "Politician disagrees, non-religious citizen + non-religious politician", "Politician disagrees, non-religious citizen + Muslim politician", "Politician disagrees, Muslim citizen + Muslim politician", "Politician disagrees, Muslim citizen + non-religious politician"),
  estimate=cit.NonRel.Mus.pol.NonRel.Mus$Estimate,
  conf.low=((cit.NonRel.Mus.pol.NonRel.Mus$Estimate)-1.96*cit.NonRel.Mus.pol.NonRel.Mus$`Std. Error`),
  conf.high=((cit.NonRel.Mus.pol.NonRel.Mus$Estimate)+1.96*cit.NonRel.Mus.pol.NonRel.Mus$`Std. Error`),
  number=c("001", "002", "003", "004", "005", "006", "007", "008"))

min(cit.NonRel.Mus.pol.NonRel.Mus.df$conf.low)
max(cit.NonRel.Mus.pol.NonRel.Mus.df$conf.high)

#ggplot
hline1.fig18.cit.NonRel.Mus.pol.NonRel.Mus.df <- data.frame(z = c(0.5,
                                                                 4.5,
                                                                 8.5)) 
hline2.fig18.cit.NonRel.Mus.pol.NonRel.Mus.df <- data.frame(z = c(2.5,
                                                                 6.5)) 

fig18.cit.NonRel.Mus.pol.NonRel.Mus.df <- ggplot(data = cit.NonRel.Mus.pol.NonRel.Mus.df, 
                                                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  ggtitle(" ") +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-0.28, .85) +
  geom_vline(xintercept = 0) + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dashed", 
             aes(yintercept = z), 
             hline1.fig18.cit.NonRel.Mus.pol.NonRel.Mus.df) +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline2.fig18.cit.NonRel.Mus.pol.NonRel.Mus.df)
fig18.cit.NonRel.Mus.pol.NonRel.Mus.df

library("patchwork")
fig18 <- fig18.cit.NonRel.Mus.pol.NonRel.Mus.df +
  plot_annotation(title = 'Does it matter whether the politician is in favor or against gender equality measures?',
                  subtitle = ' ',
                  caption = "
                  Linear models, clustered at the level of the respondent.
                  Error bars represent the 95% confidence interval. 
                  Weighted on gender, education, region and urbanization.") 
fig18

#--------------------------------#
#--- fig19 WHEN same ethnorace ---#
#--------------------------------#

FGN$PolCit.Ethnorace <- 
  interaction(FGN$Politician.Ethnorace, FGN$Citizen.Ethnorace, sep = " + ")
PolCit.Ethnorace <- mm(FGN, DVcho ~ PolCit.Ethnorace,
                       id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace

PolCit.EthnoraceDF <- data.frame(
  names=PolCit.Ethnorace$level,
  estimate=PolCit.Ethnorace$estimate*100,
  conf.low=PolCit.Ethnorace$lower*100,
  conf.high=PolCit.Ethnorace$upper*100)

PolCit.EthnoraceDF

PolCit.EthnoraceDF <- PolCit.EthnoraceDF %>% drop_na()

fig19Ethnorace <- ggplot(data = PolCit.EthnoraceDF, 
                        aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 

fig19 <- fig19Ethnorace +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same migration background?',
                  subtitle = ' ',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. Error bars represent the 95% confidence interval.
                  I omitted results with citizens with 'other' migration backgrounds due to a low number of respondents in each category. Weighted on gender, 
                  education, region and urbanization.") 
fig19

#---------------------------------#
#--- fig19 WHEN same ethnorace ---#
#---------------------------------#

#NoMig.FR
FGN.NoMig.FR <- subset(FGN, MigBckgrnd==1 & cntry=="France")
PolCit.Ethnorace.NoMig.FR <- mm(FGN.NoMig.FR, DVcho ~ Politician.MigBckgrnd,
                                id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.NoMig.FR

PolCit.Ethnorace.NoMig.FRDF <- data.frame(
  names= PolCit.Ethnorace.NoMig.FR$level,
  estimate=PolCit.Ethnorace.NoMig.FR$estimate*100,
  conf.low=PolCit.Ethnorace.NoMig.FR$lower*100,
  conf.high=PolCit.Ethnorace.NoMig.FR$upper*100)

PolCit.Ethnorace.NoMig.FRDF

PolCit.Ethnorace.NoMig.FRDF <- PolCit.Ethnorace.NoMig.FRDF %>% drop_na()

fig19Ethnorace.NoMig.FR <- ggplot(data = PolCit.Ethnorace.NoMig.FRDF, 
                                  aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "French citizens with a background in:\n\nFrance only") +
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Tur.FR
FGN.Tur.FR <- subset(FGN, MigBckgrnd==0 & cntry=="France")
PolCit.Ethnorace.Tur.FR <- mm(FGN.Tur.FR, DVcho ~ Politician.MigBckgrnd,
                              id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.Tur.FR

PolCit.Ethnorace.Tur.FRDF <- data.frame(
  names= PolCit.Ethnorace.Tur.FR$level,
  estimate=PolCit.Ethnorace.Tur.FR$estimate*100,
  conf.low=PolCit.Ethnorace.Tur.FR$lower*100,
  conf.high=PolCit.Ethnorace.Tur.FR$upper*100)

PolCit.Ethnorace.Tur.FRDF

PolCit.Ethnorace.Tur.FRDF <- PolCit.Ethnorace.Tur.FRDF %>% drop_na()

fig19Ethnorace.Tur.FR <- ggplot(data = PolCit.Ethnorace.Tur.FRDF, 
                                aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Turkey, Sub-Saharan Africa or North-Africa") +
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig19Ethnorace.Tur.FR

fig19.MigBckgrnd.FR <- fig19Ethnorace.NoMig.FR/fig19Ethnorace.Tur.FR +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same migration background?',
                  subtitle = ' ',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived NLom forced-choice question. Error bars represent the 95% confidence interval.
                  I omitted results with citizens with 'other' migration backgrounds due to a low number of respondents in each category. Weighted on gender, 
                  education, region and urbanization.") 
fig19.MigBckgrnd.FR
#ggsave(fig19.MigBckgrnd.FR, width = 7, height = 5, file="fig19.MigBckgrnd.FR.jpeg") 

#---------------------------------#
#--- fig19 WHEN same ethnorace ---#
#---------------------------------#

#NoMig.DE
FGN.NoMig.DE <- subset(FGN, MigBckgrnd==1 & cntry=="Germany")
PolCit.Ethnorace.NoMig.DE <- mm(FGN.NoMig.DE, DVcho ~ Politician.MigBckgrnd,
                                id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.NoMig.DE

PolCit.Ethnorace.NoMig.DEDF <- data.frame(
  names= PolCit.Ethnorace.NoMig.DE$level,
  estimate=PolCit.Ethnorace.NoMig.DE$estimate*100,
  conf.low=PolCit.Ethnorace.NoMig.DE$lower*100,
  conf.high=PolCit.Ethnorace.NoMig.DE$upper*100)

PolCit.Ethnorace.NoMig.DEDF

PolCit.Ethnorace.NoMig.DEDF <- PolCit.Ethnorace.NoMig.DEDF %>% drop_na()

fig19Ethnorace.NoMig.DE <- ggplot(data = PolCit.Ethnorace.NoMig.DEDF, 
                                  aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "German citizens with a background in:\n\nGermany only") +
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Tur.DE
FGN.Tur.DE <- subset(FGN, MigBckgrnd==0 & cntry=="Germany")
PolCit.Ethnorace.Tur.DE <- mm(FGN.Tur.DE, DVcho ~ Politician.MigBckgrnd,
                              id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.Tur.DE

PolCit.Ethnorace.Tur.DEDF <- data.frame(
  names= PolCit.Ethnorace.Tur.DE$level,
  estimate=PolCit.Ethnorace.Tur.DE$estimate*100,
  conf.low=PolCit.Ethnorace.Tur.DE$lower*100,
  conf.high=PolCit.Ethnorace.Tur.DE$upper*100)

PolCit.Ethnorace.Tur.DEDF

PolCit.Ethnorace.Tur.DEDF <- PolCit.Ethnorace.Tur.DEDF %>% drop_na()

fig19Ethnorace.Tur.DE <- ggplot(data = PolCit.Ethnorace.Tur.DEDF, 
                                aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Turkey or Former Soviet Union") +
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig19Ethnorace.Tur.DE

fig19.MigBckgrnd.DE <- fig19Ethnorace.NoMig.DE/fig19Ethnorace.Tur.DE +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same migration background?',
                  subtitle = ' ',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived NLom forced-choice question. Error bars represent the 95% confidence interval.
                  I omitted results with citizens with 'other' migration backgrounds due to a low number of respondents in each category. Weighted on gender, 
                  education, region and urbanization.") 
fig19.MigBckgrnd.DE
#ggsave(fig19.MigBckgrnd.DE, width = 7, height = 5, file="fig19.MigBckgrnd.DE.jpeg") 

#---------------------------------#
#--- fig19 WHEN same ethnorace ---#
#---------------------------------#

#NoMig.NL
FGN.NoMig.NL <- subset(FGN, MigBckgrnd==1 & cntry=="Netherlands")
PolCit.Ethnorace.NoMig.NL <- mm(FGN.NoMig.NL, DVcho ~ Politician.MigBckgrnd,
                                id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.NoMig.NL

PolCit.Ethnorace.NoMig.NLDF <- data.frame(
  names= PolCit.Ethnorace.NoMig.NL$level,
  estimate=PolCit.Ethnorace.NoMig.NL$estimate*100,
  conf.low=PolCit.Ethnorace.NoMig.NL$lower*100,
  conf.high=PolCit.Ethnorace.NoMig.NL$upper*100)

PolCit.Ethnorace.NoMig.NLDF

PolCit.Ethnorace.NoMig.NLDF <- PolCit.Ethnorace.NoMig.NLDF %>% drop_na()

fig19Ethnorace.NoMig.NL <- ggplot(data = PolCit.Ethnorace.NoMig.NLDF, 
                                  aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Dutch citizens with a background in:\n\nNetherlands only") +
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Tur.NL
FGN.Tur.NL <- subset(FGN, MigBckgrnd==0 & cntry=="Netherlands")
PolCit.Ethnorace.Tur.NL <- mm(FGN.Tur.NL, DVcho ~ Politician.MigBckgrnd,
                              id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.Tur.NL

PolCit.Ethnorace.Tur.NLDF <- data.frame(
  names= PolCit.Ethnorace.Tur.NL$level,
  estimate=PolCit.Ethnorace.Tur.NL$estimate*100,
  conf.low=PolCit.Ethnorace.Tur.NL$lower*100,
  conf.high=PolCit.Ethnorace.Tur.NL$upper*100)

PolCit.Ethnorace.Tur.NLDF

PolCit.Ethnorace.Tur.NLDF <- PolCit.Ethnorace.Tur.NLDF %>% drop_na()

fig19Ethnorace.Tur.NL <- ggplot(data = PolCit.Ethnorace.Tur.NLDF, 
                                aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Turkey, Moroccan or Surinamese") +
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig19Ethnorace.Tur.NL

fig19.MigBckgrnd <- fig19Ethnorace.NoMig.NL/fig19Ethnorace.Tur.NL +
  plot_annotation(title = 'When does it matter whether citizen and politician share the same migration background?',
                  subtitle = ' ',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived NLom forced-choice question. Error bars represent the 95% confidence interval.
                  I omitted results with citizens with 'other' migration backgrounds due to a low number of respondents in each category. Weighted on gender, 
                  education, region and urbanization.") 
fig19.MigBckgrnd
#ggsave(fig19.MigBckgrnd, width = 7, height = 5, file="fig19.MigBckgrnd.jpeg") 

#---------------------------------#
#--- fig19 WHEN same ethnorace ---#
#---------------------------------#

#NoMig.FGN
FGN.NoMig.FGN <- subset(FGN, MigBckgrnd==1)
PolCit.Ethnorace.NoMig.FGN <- mm(FGN.NoMig.FGN, DVcho ~ Politician.MigBckgrnd,
                                 id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.NoMig.FGN

PolCit.Ethnorace.NoMig.FGNDF <- data.frame(
  names= PolCit.Ethnorace.NoMig.FGN$level,
  estimate=PolCit.Ethnorace.NoMig.FGN$estimate*100,
  conf.low=PolCit.Ethnorace.NoMig.FGN$lower*100,
  conf.high=PolCit.Ethnorace.NoMig.FGN$upper*100)

PolCit.Ethnorace.NoMig.FGNDF

PolCit.Ethnorace.NoMig.FGNDF <- PolCit.Ethnorace.NoMig.FGNDF %>% drop_na()

fig19Ethnorace.NoMig.FGN <- ggplot(data = PolCit.Ethnorace.NoMig.FGNDF, 
                                   aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Voters with a background in:\n\nFrance/Germany/Netherlands only") +
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#Tur.FGN
FGN.Tur.FGN <- subset(FGN, MigBckgrnd==0)
PolCit.Ethnorace.Tur.FGN <- mm(FGN.Tur.FGN, DVcho ~ Politician.MigBckgrnd,
                               id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace.Tur.FGN

PolCit.Ethnorace.Tur.FGNDF <- data.frame(
  names= PolCit.Ethnorace.Tur.FGN$level,
  estimate=PolCit.Ethnorace.Tur.FGN$estimate*100,
  conf.low=PolCit.Ethnorace.Tur.FGN$lower*100,
  conf.high=PolCit.Ethnorace.Tur.FGN$upper*100)

PolCit.Ethnorace.Tur.FGNDF

PolCit.Ethnorace.Tur.FGNDF <- PolCit.Ethnorace.Tur.FGNDF %>% drop_na()

fig19Ethnorace.Tur.FGN <- ggplot(data = PolCit.Ethnorace.Tur.FGNDF, 
                                 aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Turkey, Sub-Saharan Africa, North-Africa, Former Soviet Union, Morocco, Surinam") +
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig19Ethnorace.Tur.FGN

fig19.MigBckgrnd.FGN <- fig19Ethnorace.NoMig.FGN/fig19Ethnorace.Tur.FGN +
  plot_annotation(title = 'Do voters prefer politicians with whom they share the same migration background?',
                  subtitle = ' ',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. 
                  Error bars represent the 95% confidence interval.
                  I omitted results with citizens with 'other' migration backgrounds due to a low number of respondents in each category. 
                  Weighted on gender, education, region and urbanization.") 
fig19.MigBckgrnd.FGN
#ggsave(fig19.MigBckgrnd.FGN, width = 7, height = 5, file="fig19.MigBckgrnd.FGN.jpeg") 


#------------------------------------------------------------------------------------------------------------#
#--- Amongst voters who do not know their policy position what happens when they share the same ethnorace ---#
#------------------------------------------------------------------------------------------------------------#

FGN.dk$PolCit.Ethnorace <- 
  interaction(FGN.dk$Politician.Ethnorace, FGN.dk$Citizen.Ethnorace, sep = " + ")
PolCit.Ethnorace <- mm(FGN.dk, DVcho ~ PolCit.Ethnorace,
                       id = ~ INTNR, h0 = 0.5)
PolCit.Ethnorace

PolCit.EthnoraceDF <- data.frame(
  names=PolCit.Ethnorace$level,
  estimate=PolCit.Ethnorace$estimate*100,
  conf.low=PolCit.Ethnorace$lower*100,
  conf.high=PolCit.Ethnorace$upper*100)

PolCit.EthnoraceDF
PolCit.EthnoraceDF <- PolCit.EthnoraceDF %>% drop_na()
min(PolCit.EthnoraceDF$conf.low)
max(PolCit.EthnoraceDF$conf.high)

fig20Ethnorace <- ggplot(data = PolCit.EthnoraceDF, 
                         aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  xlim(-20, 120) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 

fig20 <- fig20Ethnorace +
  plot_annotation(title = 'Amongst voters who do not know what policy position they stand for,\nwhen does it matter whether citizen and politician share the same migration background?',
                  subtitle = ' ',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. Error bars represent the 95% confidence interval.
                  I omitted results with citizens with 'other' migration backgrounds due to a low number of respondents in each category. Weighted on gender, 
                  education, region and urbanization.") 
fig20


#------------------------------#
#--- fig22 WHEN same gender ---#
#------------------------------#

#Gender H2c
FGN.dk$PolCit.Gender <- 
  interaction(FGN.dk$Politician.Gender, FGN.dk$Citizen.Gender, sep = " + ")
PolCit.Gender <- mm(FGN.dk, DVcho ~ PolCit.Gender,
                    id = ~ INTNR, h0 = 0.5, weights = ~ w8eth)
PolCit.Gender

PolCit.GenderDF <- data.frame(
  names=PolCit.Gender$level,
  estimate=PolCit.Gender$estimate*100,
  conf.low=PolCit.Gender$lower*100,
  conf.high=PolCit.Gender$upper*100,
  number=c("001", "004", "003", "002"))

PolCit.GenderDF

fig22Gender <- ggplot(data = PolCit.GenderDF, 
                      aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(31.7, 68.5) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

library("patchwork")
fig22 <- fig22Gender +
  plot_annotation(title = 'Amongst voters who do not know what policy position they stand for,\ndoes it matter whether citizen and politician share the same gender?',
                  subtitle = ' ',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. 
                  Error bars represent the 95% confidence interval.
                  Weighted on migration background, gender, education, region and urbanization.") 
fig22 

#----------------------#
#--- extra appendix ---#
#----------------------#

#-----------------------------------------------------------------------------------#
#---- what do DK voters prefer - progressive or conservative Muslim politicians? ---#
#-----------------------------------------------------------------------------------#

#.equal.pay.by.law
FGN.dk$PolCit.CP.equal.pay.by.law <- 
  interaction(FGN.dk$Politician.is.Muslim, FGN.dk$relMus, FGN.dk$Politician.Policy.Position.equal.pay.by.law, sep = " + ")
PolCit.CP.equal.pay.by.law <- mm(FGN.dk, DVcho ~ PolCit.CP.equal.pay.by.law,
                                 id = ~ INTNR, h0 = 0.5)
PolCit.CP.equal.pay.by.law

PolCit.CP.equal.pay.by.lawDF <- data.frame(
  names=PolCit.CP.equal.pay.by.law$level,
  estimate=PolCit.CP.equal.pay.by.law$estimate*100,
  conf.low=PolCit.CP.equal.pay.by.law$lower*100,
  conf.high=PolCit.CP.equal.pay.by.law$upper*100,  number=c("003", "001", "002", "004"))

PolCit.CP.equal.pay.by.lawDF
min(PolCit.CP.equal.pay.by.lawDF$conf.low)
max(PolCit.CP.equal.pay.by.lawDF$conf.high)

fig23CP.equal.pay.by.law <- ggplot(data = PolCit.CP.equal.pay.by.lawDF, 
                                   aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-30, 130) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")
#fig23CP.equal.pay.by.law

library("patchwork")
fig23.equal.pay.by.law <- fig23CP.equal.pay.by.law +
  plot_annotation(title = 'Amongst voters who answered the middle option when being asked their policy position,\nwhat kind of politician and position do they prefer? ',
                  subtitle = 'With regard to the statement on equal pay',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. Error bars represent the 95% confidence interval.
                  Weighted on gender, education, region and urbanization.") 
fig23.equal.pay.by.law 

#.homoco.may.adopt
FGN.dk$PolCit.CP.homoco.may.adopt <- 
  interaction(FGN.dk$Politician.is.Muslim, FGN.dk$relMus, FGN.dk$Politician.Policy.Position.homoco.may.adopt, sep = " + ")
PolCit.CP.homoco.may.adopt <- mm(FGN.dk, DVcho ~ PolCit.CP.homoco.may.adopt,
                                 id = ~ INTNR, h0 = 0.5)
PolCit.CP.homoco.may.adopt

PolCit.CP.homoco.may.adoptDF <- data.frame(
  names=PolCit.CP.homoco.may.adopt$level,
  estimate=PolCit.CP.homoco.may.adopt$estimate*100,
  conf.low=PolCit.CP.homoco.may.adopt$lower*100,
  conf.high=PolCit.CP.homoco.may.adopt$upper*100,  number=c("003", "001", "002", "004"))

PolCit.CP.homoco.may.adoptDF
min(PolCit.CP.homoco.may.adoptDF$conf.low)
max(PolCit.CP.homoco.may.adoptDF$conf.high)

fig23CP.homoco.may.adopt <- ggplot(data = PolCit.CP.homoco.may.adoptDF, 
                                   aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-30, 130) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")
#fig23CP.homoco.may.adopt

library("patchwork")
fig23.homoco.may.adopt <- fig23CP.homoco.may.adopt +
  plot_annotation(title = 'Amongst voters who answered the middle option when being asked their policy position,\nwhat kind of politician and position do they prefer? ',
                  subtitle = 'With regard to the statement that homosexual couples should be allowed to adopt children',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. Error bars represent the 95% confidence interval.
                  Weighted on gender, education, region and urbanization.") 
fig23.homoco.may.adopt 

#.islam.not.restricted
FGN.dk$PolCit.CP.islam.not.restricted <- 
  interaction(FGN.dk$Politician.is.Muslim, FGN.dk$relMus, FGN.dk$Politician.Policy.Position.islam.not.restricted, sep = " + ")
PolCit.CP.islam.not.restricted <- mm(FGN.dk, DVcho ~ PolCit.CP.islam.not.restricted,
                                     id = ~ INTNR, h0 = 0.5)
PolCit.CP.islam.not.restricted

PolCit.CP.islam.not.restrictedDF <- data.frame(
  names=PolCit.CP.islam.not.restricted$level,
  estimate=PolCit.CP.islam.not.restricted$estimate*100,
  conf.low=PolCit.CP.islam.not.restricted$lower*100,
  conf.high=PolCit.CP.islam.not.restricted$upper*100,  number=c("003", "001", "002", "004"))

PolCit.CP.islam.not.restrictedDF
min(PolCit.CP.islam.not.restrictedDF$conf.low)
max(PolCit.CP.islam.not.restrictedDF$conf.high)

fig23CP.islam.not.restricted <- ggplot(data = PolCit.CP.islam.not.restrictedDF, 
                                       aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-30, 130) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")
#fig23CP.islam.not.restricted

library("patchwork")
fig23.islam.not.restricted <- fig23CP.islam.not.restricted +
  plot_annotation(title = 'Amongst voters who answered the middle option when being asked their policy position,\nwhat kind of politician and position do they prefer? ',
                  subtitle = 'With regard to the statement islam is not restricted',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. Error bars represent the 95% confidence interval.
                  Weighted on gender, education, region and urbanization.") 
fig23.islam.not.restricted 

#.immigrants.R.asset
FGN.dk$PolCit.CP.immigrants.R.asset <- 
  interaction(FGN.dk$Politician.is.Muslim, FGN.dk$relMus, FGN.dk$Politician.Policy.Position.immigrants.R.asset, sep = " + ")
PolCit.CP.immigrants.R.asset <- mm(FGN.dk, DVcho ~ PolCit.CP.immigrants.R.asset,
                                   id = ~ INTNR, h0 = 0.5)
PolCit.CP.immigrants.R.asset

PolCit.CP.immigrants.R.assetDF <- data.frame(
  names=PolCit.CP.immigrants.R.asset$level,
  estimate=PolCit.CP.immigrants.R.asset$estimate*100,
  conf.low=PolCit.CP.immigrants.R.asset$lower*100,
  conf.high=PolCit.CP.immigrants.R.asset$upper*100,  number=c("003", "001", "002", "004"))

PolCit.CP.immigrants.R.assetDF
min(PolCit.CP.immigrants.R.assetDF$conf.low)
max(PolCit.CP.immigrants.R.assetDF$conf.high)

fig23CP.immigrants.R.asset <- ggplot(data = PolCit.CP.immigrants.R.assetDF, 
                                     aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-30, 130) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")
#fig23CP.immigrants.R.asset

library("patchwork")
fig23.immigrants.R.asset <- fig23CP.immigrants.R.asset +
  plot_annotation(title = 'Amongst voters who answered the middle option when being asked their policy position,\nwhat kind of politician and position do they prefer? ',
                  subtitle = 'With regard to the statement that immigrants are an asset',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. Error bars represent the 95% confidence interval.
                  Weighted on gender, education, region and urbanization.") 
fig23.immigrants.R.asset 

#.tax.rich.higher
FGN.dk$PolCit.CP.tax.rich.higher <- 
  interaction(FGN.dk$Politician.is.Muslim, FGN.dk$relMus, FGN.dk$Politician.Policy.Position.tax.rich.higher, sep = " + ")
PolCit.CP.tax.rich.higher <- mm(FGN.dk, DVcho ~ PolCit.CP.tax.rich.higher,
                                id = ~ INTNR, h0 = 0.5)
PolCit.CP.tax.rich.higher

PolCit.CP.tax.rich.higherDF <- data.frame(
  names=PolCit.CP.tax.rich.higher$level,
  estimate=PolCit.CP.tax.rich.higher$estimate*100,
  conf.low=PolCit.CP.tax.rich.higher$lower*100,
  conf.high=PolCit.CP.tax.rich.higher$upper*100,  number=c("003", "001", "002", "004"))

PolCit.CP.tax.rich.higherDF
min(PolCit.CP.tax.rich.higherDF$conf.low)
max(PolCit.CP.tax.rich.higherDF$conf.high)

fig23CP.tax.rich.higher <- ggplot(data = PolCit.CP.tax.rich.higherDF, 
                                  aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-30, 130) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")
#fig23CP.tax.rich.higher

library("patchwork")
fig23.tax.rich.higher <- fig23CP.tax.rich.higher +
  plot_annotation(title = 'Amongst voters who answered the middle option when being asked their policy position,\nwhat kind of politician and position do they prefer? ',
                  subtitle = 'With regard to the statement on taxing the rich',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. Error bars represent the 95% confidence interval.
                  Weighted on gender, education, region and urbanization.") 
fig23.tax.rich.higher 

#.raise.fuel.price
FGN.dk$PolCit.CP.raise.fuel.price <- 
  interaction(FGN.dk$Politician.is.Muslim, FGN.dk$relMus, FGN.dk$Politician.Policy.Position.raise.fuel.price, sep = " + ")
PolCit.CP.raise.fuel.price <- mm(FGN.dk, DVcho ~ PolCit.CP.raise.fuel.price,
                                 id = ~ INTNR, h0 = 0.5)
PolCit.CP.raise.fuel.price

PolCit.CP.raise.fuel.priceDF <- data.frame(
  names=PolCit.CP.raise.fuel.price$level,
  estimate=PolCit.CP.raise.fuel.price$estimate*100,
  conf.low=PolCit.CP.raise.fuel.price$lower*100,
  conf.high=PolCit.CP.raise.fuel.price$upper*100,  number=c("003", "001", "002", "004"))

PolCit.CP.raise.fuel.priceDF
min(PolCit.CP.raise.fuel.priceDF$conf.low)
max(PolCit.CP.raise.fuel.priceDF$conf.high)

fig23CP.raise.fuel.price <- ggplot(data = PolCit.CP.raise.fuel.priceDF, 
                                   aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-10, 116) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")
#fig23CP.raise.fuel.price

library("patchwork")
fig23.raise.fuel.price <- fig23CP.raise.fuel.price +
  plot_annotation(title = 'Amongst voters who answered the middle option when being asked their policy position,\nwhat kind of politician and position do they prefer? ',
                  subtitle = 'With regard to the statement on raising the fuel prices',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. Error bars represent the 95% confidence interval.
                  Weighted on gender, education, region and urbanization.") 
fig23.raise.fuel.price 

#.more.com.climcha
FGN.dk$PolCit.CP.more.com.climcha <- 
  interaction(FGN.dk$Politician.is.Muslim, FGN.dk$relMus, FGN.dk$Politician.Policy.Position.more.com.climcha, sep = " + ")
PolCit.CP.more.com.climcha <- mm(FGN.dk, DVcho ~ PolCit.CP.more.com.climcha,
                                 id = ~ INTNR, h0 = 0.5)
PolCit.CP.more.com.climcha

PolCit.CP.more.com.climchaDF <- data.frame(
  names=PolCit.CP.more.com.climcha$level,
  estimate=PolCit.CP.more.com.climcha$estimate*100,
  conf.low=PolCit.CP.more.com.climcha$lower*100,
  conf.high=PolCit.CP.more.com.climcha$upper*100,  number=c("003", "001", "002", "004"))

PolCit.CP.more.com.climchaDF
min(PolCit.CP.more.com.climchaDF$conf.low)
max(PolCit.CP.more.com.climchaDF$conf.high)

fig23CP.more.com.climcha <- ggplot(data = PolCit.CP.more.com.climchaDF, 
                                   aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-30, 130) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")
#fig23CP.more.com.climcha

library("patchwork")
fig23.more.com.climcha <- fig23CP.more.com.climcha +
  plot_annotation(title = 'Amongst voters who answered the middle option when being asked their policy position,\nwhat kind of politician and position do they prefer? ',
                  subtitle = 'With regard to the statement we should do more to combat climate change',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. Error bars represent the 95% confidence interval.
                  Weighted on gender, education, region and urbanization.") 
fig23.more.com.climcha 

#.raise.supp.unemp
FGN.dk$PolCit.CP.raise.supp.unemp <- 
  interaction(FGN.dk$Politician.is.Muslim, FGN.dk$relMus, FGN.dk$Politician.Policy.Position.raise.supp.unemp, sep = " + ")
PolCit.CP.raise.supp.unemp <- mm(FGN.dk, DVcho ~ PolCit.CP.raise.supp.unemp,
                                 id = ~ INTNR, h0 = 0.5)
PolCit.CP.raise.supp.unemp

PolCit.CP.raise.supp.unempDF <- data.frame(
  names=PolCit.CP.raise.supp.unemp$level,
  estimate=PolCit.CP.raise.supp.unemp$estimate*100,
  conf.low=PolCit.CP.raise.supp.unemp$lower*100,
  conf.high=PolCit.CP.raise.supp.unemp$upper*100,  number=c("003", "001", "002", "004"))

PolCit.CP.raise.supp.unempDF
min(PolCit.CP.raise.supp.unempDF$conf.low)
max(PolCit.CP.raise.supp.unempDF$conf.high)

fig23CP.raise.supp.unemp <- ggplot(data = PolCit.CP.raise.supp.unempDF, 
                                   aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(-30, 130) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")
#fig23CP.raise.supp.unemp

library("patchwork")
fig23.raise.supp.unemp <- fig23CP.raise.supp.unemp +
  plot_annotation(title = 'Amongst voters who answered the middle option when being asked their policy position,\nwhat kind of politician and position do they prefer? ',
                  subtitle = 'With regard to the statement raising support for the unemployed',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. Error bars represent the 95% confidence interval.
                  Weighted on gender, education, region and urbanization.") 
fig23.raise.supp.unemp 

#--------------------------------------------------------------#
#--- level of identification and substantive representation ---#
#--------------------------------------------------------------#
#Weird result - the more a Muslim identifies as Muslim, the more negative they are about Christian politicians who are in favor of Islam
#also weird: the more a Turkish respondent identifies as Turkish, the more negative they are about Turkish politicians who are pro immigration...!?
#maybe just conclude: this ethnocentrism scale is weird, so don't do anything else with it.

#Being Muslim
#agree
FGNMuslim <- subset(FGN, Politician.Religion=="Muslim politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="Christian politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="non-religious politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#disagree
FGNMuslim <- subset(FGN, Politician.Religion=="Muslim politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="Christian politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="non-religious politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#Level of Muslim identification
#agree
FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Muslim politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Christian politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="non-religious politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#disagree
FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Muslim politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Christian politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="non-religious politician" & Politician.Policy.Position.islam.not.restricted=="islam.not.restricted politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#Being Turkish
#agree
FGNTurkish <- subset(FGN, Politician.Ethnorace=="Turkish politician" & Politician.Policy.Position.immigrants.R.asset=="immigrants.R.asset politician agrees" )
Turkish.subset.interaction <- miceadds::lm.cluster(
  data=FGNTurkish, 
  formula = FGNTurkish$DVcho ~ 
    FGNTurkish$catTur,
  cluster=FGNTurkish$INTNR)
summary(Turkish.subset.interaction)

FGNTurkish <- subset(FGN, Politician.Ethnorace=="Politician without migration background" & Politician.Policy.Position.immigrants.R.asset=="immigrants.R.asset politician agrees" )
Turkish.subset.interaction <- miceadds::lm.cluster(
  data=FGNTurkish, 
  formula = FGNTurkish$DVcho ~ 
    FGNTurkish$catTur,
  cluster=FGNTurkish$INTNR)
summary(Turkish.subset.interaction)

#disagree
FGNTurkish <- subset(FGN, Politician.Ethnorace=="Turkish politician" & Politician.Policy.Position.immigrants.R.asset=="immigrants.R.asset politician disagrees" )
Turkish.subset.interaction <- miceadds::lm.cluster(
  data=FGNTurkish, 
  formula = FGNTurkish$DVcho ~ 
    FGNTurkish$catTur,
  cluster=FGNTurkish$INTNR)
summary(Turkish.subset.interaction)

FGNTurkish <- subset(FGN, Politician.Ethnorace=="Politician without migration background" & Politician.Policy.Position.immigrants.R.asset=="immigrants.R.asset politician disagrees" )
Turkish.subset.interaction <- miceadds::lm.cluster(
  data=FGNTurkish, 
  formula = FGNTurkish$DVcho ~ 
    FGNTurkish$catTur,
  cluster=FGNTurkish$INTNR)
summary(Turkish.subset.interaction)

#Level of Turkish identification
#agree
FGNTurkish <- subset(FGN, catTur=="Turkish citizen" & Politician.Ethnorace=="Turkish politician" & Politician.Policy.Position.immigrants.R.asset=="immigrants.R.asset politician agrees" )
Turkish.subset.interaction <- miceadds::lm.cluster(
  data=FGNTurkish, 
  formula = FGNTurkish$DVcho ~ 
    FGNTurkish$eth.id.Tur,
  cluster=FGNTurkish$INTNR)
summary(Turkish.subset.interaction)

FGNTurkish <- subset(FGN, catTur=="Turkish citizen" & Politician.Ethnorace=="Politician without migration background" & Politician.Policy.Position.immigrants.R.asset=="immigrants.R.asset politician agrees" )
Turkish.subset.interaction <- miceadds::lm.cluster(
  data=FGNTurkish, 
  formula = FGNTurkish$DVcho ~ 
    FGNTurkish$eth.id.Tur,
  cluster=FGNTurkish$INTNR)
summary(Turkish.subset.interaction)

#disagree
FGNTurkish <- subset(FGN, catTur=="Turkish citizen" & Politician.Ethnorace=="Turkish politician" & Politician.Policy.Position.immigrants.R.asset=="immigrants.R.asset politician disagrees" )
Turkish.subset.interaction <- miceadds::lm.cluster(
  data=FGNTurkish, 
  formula = FGNTurkish$DVcho ~ 
    FGNTurkish$eth.id.Tur,
  cluster=FGNTurkish$INTNR)
summary(Turkish.subset.interaction)

FGNTurkish <- subset(FGN, catTur=="Turkish citizen" & Politician.Ethnorace=="Politician without migration background" & Politician.Policy.Position.immigrants.R.asset=="immigrants.R.asset politician disagrees" )
Turkish.subset.interaction <- miceadds::lm.cluster(
  data=FGNTurkish, 
  formula = FGNTurkish$DVcho ~ 
    FGNTurkish$eth.id.Tur,
  cluster=FGNTurkish$INTNR)
summary(Turkish.subset.interaction)

#homoco.may.adopt
#Being Muslim
#agree
FGNMuslim <- subset(FGN, Politician.Religion=="Muslim politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="Christian politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="non-religious politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#disagree
FGNMuslim <- subset(FGN, Politician.Religion=="Muslim politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="Christian politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="non-religious politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#Level of Muslim identification
#agree
FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Muslim politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Christian politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="non-religious politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#disagree
FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Muslim politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Christian politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="non-religious politician" & Politician.Policy.Position.homoco.may.adopt=="homoco.may.adopt politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#equal.pay.by.law
#Being Muslim
#agree
FGNMuslim <- subset(FGN, Politician.Religion=="Muslim politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="Christian politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="non-religious politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#disagree
FGNMuslim <- subset(FGN, Politician.Religion=="Muslim politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="Christian politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, Politician.Religion=="non-religious politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$relMus01,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#Level of Muslim identification
#agree
FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Muslim politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Christian politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="non-religious politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician agrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#disagree
FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Muslim politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="Christian politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

FGNMuslim <- subset(FGN, relMus=="Muslim citizen" & Politician.Religion=="non-religious politician" & Politician.Policy.Position.equal.pay.by.law=="equal.pay.by.law politician disagrees" )
Muslim.subset.interaction <- miceadds::lm.cluster(
  data=FGNMuslim, 
  formula = FGNMuslim$DVcho ~ 
    FGNMuslim$rel.id.Mus,
  cluster=FGNMuslim$INTNR)
summary(Muslim.subset.interaction)

#-----------------------------------#
#--- Cross-pressured voters fig24 ---#
#-----------------------------------#

FGN <- FGN %>% mutate(PolCit.MusTur = case_when(
  #Turkish Muslim citizens
  Politician.Ethnorace == "Turkish politician" & 
    Politician.Religion == "Muslim politician" & 
    catTur == "Turkish citizen" & 
    relMus == "Muslim citizen" ~
    "Politician and citizen are Turkish Muslims",
  
  Politician.Ethnorace == "Politician without migration background" & 
    Politician.Religion == "Muslim politician" & 
    catTur == "Turkish citizen" & 
    relMus == "Muslim citizen" ~
    "Politician is native and Muslim and citizen is Turkish Muslim",
  
  Politician.Ethnorace == "Turkish politician" & 
    Politician.Religion == "non-religious politician" & 
    catTur == "Turkish citizen" & 
    relMus == "Muslim citizen" ~
    "Politician is non-religious and Turkish and citizen is Turkish Muslim",
  
  Politician.Ethnorace == "Politician without migration background" & 
    Politician.Religion == "non-religious politician" & 
    catTur == "Turkish citizen" & 
    relMus == "Muslim citizen" ~
    "Politician is non-religious native and citizen is Turkish Muslim",
  
  #native non-religious citizens
  Politician.Ethnorace == "Turkish politician" & 
    Politician.Religion == "Muslim politician" & 
    catNoMig == 1 & 
    relNon == 1 ~
    "Politician and citizen are non-religious natives",
  
  Politician.Ethnorace == "Politician without migration background" & 
    Politician.Religion == "Muslim politician" & 
    catNoMig == 1 & 
    relNon == 1 ~
    "Politician is native and Muslim and citizen is non-religious native",
  
  Politician.Ethnorace == "Turkish politician" & 
    Politician.Religion == "non-religious politician" & 
    catNoMig == 1 & 
    relNon == 1 ~
    "Politician is non-religious and Turkish and citizen is non-religious native",
  
  Politician.Ethnorace == "Politician without migration background" & 
    Politician.Religion == "non-religious politician" & 
    catNoMig == 1 & 
    relNon == 1 ~
    "Politician is non-religious native and citizen is non-religious native")) 
FGN$PolCit.MusTur <- as.factor(FGN$PolCit.MusTur)

PolCit.MusTur <- mm(FGN, DVcho ~ PolCit.MusTur,
                    id = ~ INTNR, h0 = 0.5)
PolCit.MusTur

PolCit.MusTurDF <- data.frame(
  names=PolCit.MusTur$level,
  estimate=PolCit.MusTur$estimate*100,
  conf.low=PolCit.MusTur$lower*100,
  conf.high=PolCit.MusTur$upper*100,  number=c("003", "001", "002", "004"))

PolCit.MusTurDF
min(PolCit.MusTurDF$conf.low)
max(PolCit.MusTurDF$conf.high)

fig6MusTur <- ggplot(data = PolCit.MusTurDF, 
                     aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of the votes (marginal means)") + 
  xlim(34, 70) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot")

#fig6MusTur

library("patchwork")
fig24 <- fig6MusTur +
  plot_annotation(title = 'What do cross-pressured voters do?',
                  subtitle = 'When forced to choose between a politician with the same religion and a politician with the same migration background,\nwhat does a voter do?',
                  caption = "
                  Marginal means. 
                  Dependent variable: Likelihood of voting for a politician derived from forced-choice question. Error bars represent the 95% confidence interval.
                  Weighted on gender, education, region and urbanization.") 
fig24 

#----------------------------------------#
#--- distributions policy preferences ---#
#----------------------------------------#

#tax.rich.higher
FGN$tax.rich.higher010 <- FGN$tax.rich.higher*10 
#FGN.NonRel.cit
FGN.NonRel.cit <- subset(FGN, Citizen.Religion=="non-religious citizen")
Hist1a.tax.rich.higher <- ggplot(FGN.NonRel.cit, aes(x = factor(tax.rich.higher010), 
                                                      weight = w8eth,
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Distribution of responses to statement:\n'The tax rate for the rich must be higher'\n\nAmongst non-religious citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

#FGN.Muslim.cit
FGN.Muslim.cit <- subset(FGN, Citizen.Religion=="Muslim citizen")
Hist1b.tax.rich.higher <- ggplot(FGN.Muslim.cit, aes(x = factor(tax.rich.higher010), 
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                         Fully agree") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Amongst Muslim citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

library("patchwork")
fig25.tax.rich.higher <- Hist1a.tax.rich.higher/Hist1b.tax.rich.higher
fig25.tax.rich.higher

#raise.supp.unemp
FGN$raise.supp.unemp010 <- FGN$raise.supp.unemp*10 
#FGN.NonRel.cit
FGN.NonRel.cit <- subset(FGN, Citizen.Religion=="non-religious citizen")
Hist1a.raise.supp.unemp <- ggplot(FGN.NonRel.cit, aes(x = factor(raise.supp.unemp010), 
                                                      weight = w8eth,
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Distribution of responses to statement:\n'Our government should raise the support for the unemployed.'\n\nAmongst non-religious citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

#FGN.Muslim.cit
FGN.Muslim.cit <- subset(FGN, Citizen.Religion=="Muslim citizen")
Hist1b.raise.supp.unemp <- ggplot(FGN.Muslim.cit, aes(x = factor(raise.supp.unemp010), 
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                         Fully agree") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Amongst Muslim citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

library("patchwork")
fig25.raise.supp.unemp <- Hist1a.raise.supp.unemp/Hist1b.raise.supp.unemp
fig25.raise.supp.unemp

#more.com.climcha
FGN$more.com.climcha010 <- FGN$more.com.climcha*10 
#FGN.NonRel.cit
FGN.NonRel.cit <- subset(FGN, Citizen.Religion=="non-religious citizen")
Hist1a.more.com.climcha <- ggplot(FGN.NonRel.cit, aes(x = factor(more.com.climcha010), 
                                                      weight = w8eth,
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Distribution of responses to statement:\n'Our government should do more to combat climate change than now'\n\nAmongst non-religious citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

#FGN.Muslim.cit
FGN.Muslim.cit <- subset(FGN, Citizen.Religion=="Muslim citizen")
Hist1b.more.com.climcha <- ggplot(FGN.Muslim.cit, aes(x = factor(more.com.climcha010), 
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                         Fully agree") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Amongst Muslim citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

library("patchwork")
fig25.more.com.climcha <- Hist1a.more.com.climcha/Hist1b.more.com.climcha
fig25.more.com.climcha

#raise.fuel.price
FGN$raise.fuel.price010 <- FGN$raise.fuel.price*10 
#FGN.NonRel.cit
FGN.NonRel.cit <- subset(FGN, Citizen.Religion=="non-religious citizen")
Hist1a.raise.fuel.price <- ggplot(FGN.NonRel.cit, aes(x = factor(raise.fuel.price010), 
                                                      weight = w8eth,
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Distribution of responses to statement:\n'Our government needs to raise fuel prices'\n\nAmongst non-religious citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

#FGN.Muslim.cit
FGN.Muslim.cit <- subset(FGN, Citizen.Religion=="Muslim citizen")
Hist1b.raise.fuel.price <- ggplot(FGN.Muslim.cit, aes(x = factor(raise.fuel.price010), 
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                         Fully agree") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Amongst Muslim citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

library("patchwork")
fig25.raise.fuel.price <- Hist1a.raise.fuel.price/Hist1b.raise.fuel.price
fig25.raise.fuel.price

#immigrants.R.asset
FGN$immigrants.R.asset010 <- FGN$immigrants.R.asset*10 
#FGN.NonRel.cit
FGN.NonRel.cit <- subset(FGN, Citizen.Religion=="non-religious citizen")
Hist1a.immigrants.R.asset <- ggplot(FGN.NonRel.cit, aes(x = factor(immigrants.R.asset010), 
                                                      weight = w8eth,
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Distribution of responses to statement:\n'Immigrants are an asset to our country'\n\nAmongst non-religious citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

#FGN.Muslim.cit
FGN.Muslim.cit <- subset(FGN, Citizen.Religion=="Muslim citizen")
Hist1b.immigrants.R.asset <- ggplot(FGN.Muslim.cit, aes(x = factor(immigrants.R.asset010), 
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                         Fully agree") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Amongst Muslim citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

library("patchwork")
fig25.immigrants.R.asset <- Hist1a.immigrants.R.asset/Hist1b.immigrants.R.asset
fig25.immigrants.R.asset

#islam.not.restricted
FGN$islam.not.restricted010 <- FGN$islam.not.restricted*10 
#FGN.NonRel.cit
FGN.NonRel.cit <- subset(FGN, Citizen.Religion=="non-religious citizen")
Hist1a.islam.not.restricted <- ggplot(FGN.NonRel.cit, aes(x = factor(islam.not.restricted010), 
                                                          weight = w8eth,
                                                          label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Amongst non-religious citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

#FGN.Muslim.cit
FGN.Muslim.cit <- subset(FGN, Citizen.Religion=="Muslim citizen")
Hist1b.islam.not.restricted <- ggplot(FGN.Muslim.cit, aes(x = factor(islam.not.restricted010), 
                                                          label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                            Fully agree") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Amongst Muslim citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

library("patchwork")
fig25.islam.not.restricted <- Hist1a.islam.not.restricted/Hist1b.islam.not.restricted + 
  plot_annotation(title = "Distribution of responses to statement:\n'Islam should not be restricted by law'",
                  #subtitle = ' ',
                  caption = "
                  I weighted the non-religious subset on migration background")
fig25.islam.not.restricted

#equal.pay.by.law
FGN$equal.pay.by.law010 <- FGN$equal.pay.by.law*10 
#FGN.NonRel.cit
FGN.NonRel.cit <- subset(FGN, Citizen.Religion=="non-religious citizen")
Hist1a.equal.pay.by.law <- ggplot(FGN.NonRel.cit, aes(x = factor(equal.pay.by.law010), 
                                                      weight = w8eth,
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Distribution of responses to statement:\n'That men and women receive equal pay for equal work should be regulated by law'\n\nAmongst non-religious citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

#FGN.Muslim.cit
FGN.Muslim.cit <- subset(FGN, Citizen.Religion=="Muslim citizen")
Hist1b.equal.pay.by.law <- ggplot(FGN.Muslim.cit, aes(x = factor(equal.pay.by.law010), 
                                                      #weight = w8,
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                         Fully agree") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Amongst Muslim citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

library("patchwork")
fig25.equal.pay.by.law <- Hist1a.equal.pay.by.law/Hist1b.equal.pay.by.law
fig25.equal.pay.by.law

#homoco.may.adopt
FGN$homoco.may.adopt010 <- FGN$homoco.may.adopt*10 
#FGN.NonRel.cit
FGN.NonRel.cit <- subset(FGN, Citizen.Religion=="non-religious citizen")
Hist1a.homoco.may.adopt <- ggplot(FGN.NonRel.cit, aes(x = factor(homoco.may.adopt010), 
                                                      weight = w8eth,
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Distribution of responses to statement:\n'Homosexual couples should be allowed to adopt children'\n\nAmongst non-religious citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

#FGN.Muslim.cit
FGN.Muslim.cit <- subset(FGN, Citizen.Religion=="Muslim citizen")
Hist1b.homoco.may.adopt <- ggplot(FGN.Muslim.cit, aes(x = factor(homoco.may.adopt010), 
                                                      label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                         Fully agree") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Amongst Muslim citizens") + 
  scale_y_continuous(limits = c(0, .57),
                     labels = scales::percent_format(accuracy = 1L)) +
  theme(plot.title.position = "plot")

library("patchwork")
fig25.homoco.may.adopt <- Hist1a.homoco.may.adopt/Hist1b.homoco.may.adopt
fig25.homoco.may.adopt

#-----------------------------------------#
#--- average policy position per group ---#
#-----------------------------------------#
#tax.rich.higher
difference.in.w8ed.mean.tax.rich.higher <- weighted.mean(FGN.NonRel.cit$tax.rich.higher, FGN.NonRel.cit$w8eth, na.rm = TRUE) - 
  mean(FGN.Muslim.cit$tax.rich.higher, na.rm = TRUE)
difference.in.w8ed.mean.tax.rich.higher
weighted.mean(FGN.NonRel.cit$tax.rich.higher, FGN.NonRel.cit$w8eth, na.rm = TRUE)
mean(FGN.Muslim.cit$tax.rich.higher, na.rm = TRUE)

#raise.supp.unemp
difference.in.w8ed.mean.raise.supp.unemp <- weighted.mean(FGN.NonRel.cit$raise.supp.unemp, FGN.NonRel.cit$w8eth, na.rm = TRUE) - 
  mean(FGN.Muslim.cit$raise.supp.unemp, na.rm = TRUE)
difference.in.w8ed.mean.raise.supp.unemp
weighted.mean(FGN.NonRel.cit$raise.supp.unemp, FGN.NonRel.cit$w8eth, na.rm = TRUE)
mean(FGN.Muslim.cit$raise.supp.unemp, na.rm = TRUE)

#more.com.climcha
difference.in.w8ed.mean.more.com.climcha <- weighted.mean(FGN.NonRel.cit$more.com.climcha, FGN.NonRel.cit$w8eth, na.rm = TRUE) - 
  mean(FGN.Muslim.cit$more.com.climcha, na.rm = TRUE)
difference.in.w8ed.mean.more.com.climcha
weighted.mean(FGN.NonRel.cit$more.com.climcha, FGN.NonRel.cit$w8eth, na.rm = TRUE)
mean(FGN.Muslim.cit$more.com.climcha, na.rm = TRUE)

#raise.fuel.price
difference.in.w8ed.mean.raise.fuel.price <- weighted.mean(FGN.NonRel.cit$raise.fuel.price, FGN.NonRel.cit$w8eth, na.rm = TRUE) - 
  mean(FGN.Muslim.cit$raise.fuel.price, na.rm = TRUE)
difference.in.w8ed.mean.raise.fuel.price
weighted.mean(FGN.NonRel.cit$raise.fuel.price, FGN.NonRel.cit$w8eth, na.rm = TRUE)
mean(FGN.Muslim.cit$raise.fuel.price, na.rm = TRUE)

#immigrants.R.asset
difference.in.w8ed.mean.immigrants.R.asset <- weighted.mean(FGN.NonRel.cit$immigrants.R.asset, FGN.NonRel.cit$w8eth, na.rm = TRUE) - 
  mean(FGN.Muslim.cit$immigrants.R.asset, na.rm = TRUE)
difference.in.w8ed.mean.immigrants.R.asset
weighted.mean(FGN.NonRel.cit$immigrants.R.asset, FGN.NonRel.cit$w8eth, na.rm = TRUE)
mean(FGN.Muslim.cit$immigrants.R.asset, na.rm = TRUE)

#islam.not.restricted
difference.in.w8ed.mean.islam.not.restricted <- weighted.mean(FGN.NonRel.cit$islam.not.restricted, FGN.NonRel.cit$w8eth, na.rm = TRUE) - 
  mean(FGN.Muslim.cit$islam.not.restricted, na.rm = TRUE)
difference.in.w8ed.mean.islam.not.restricted
weighted.mean(FGN.NonRel.cit$islam.not.restricted, FGN.NonRel.cit$w8eth, na.rm = TRUE)
mean(FGN.Muslim.cit$islam.not.restricted, na.rm = TRUE)

#equal.pay.by.law
difference.in.w8ed.mean.equal.pay.by.law <- weighted.mean(FGN.NonRel.cit$equal.pay.by.law, FGN.NonRel.cit$w8eth, na.rm = TRUE) - 
  mean(FGN.Muslim.cit$equal.pay.by.law, na.rm = TRUE)
difference.in.w8ed.mean.equal.pay.by.law
weighted.mean(FGN.NonRel.cit$equal.pay.by.law, FGN.NonRel.cit$w8eth, na.rm = TRUE)
mean(FGN.Muslim.cit$equal.pay.by.law, na.rm = TRUE)

#homoco.may.adopt
difference.in.w8ed.mean.homoco.may.adopt <- weighted.mean(FGN.NonRel.cit$homoco.may.adopt, FGN.NonRel.cit$w8eth, na.rm = TRUE) - 
  mean(FGN.Muslim.cit$homoco.may.adopt, na.rm = TRUE)
difference.in.w8ed.mean.homoco.may.adopt
weighted.mean(FGN.NonRel.cit$homoco.may.adopt, FGN.NonRel.cit$w8eth, na.rm = TRUE)
mean(FGN.Muslim.cit$homoco.may.adopt, na.rm = TRUE)

#make visual
FGN <- FGN %>% mutate(Citizen.Religion.MusNon = case_when(binidrel2 == "Muslim" ~ "Muslim",
                                                   #binidrel2 == "Christian" ~ "Christian citizen",
                                                   #binidrel2 == "Other" ~ "Other citizen",
                                                   binidrel2 == "Non-religious" ~ "non-religious")) 
FGN$Citizen.Religion.MusNon <- as.factor(FGN$Citizen.Religion.MusNon)

#tax.rich.higher
Av.PP.tax.rich.higher <- mm(FGN, tax.rich.higher.resp.agree ~ Citizen.Religion.MusNon,
                            id = ~ INTNR, h0 = 0.5)
Av.PP.tax.rich.higher
#raise.supp.unemp
Av.PP.raise.supp.unemp <- mm(FGN, raise.supp.unemp.resp.agree ~ Citizen.Religion.MusNon,
                                              id = ~ INTNR, h0 = 0.5)
Av.PP.raise.supp.unemp
#more.com.climcha
Av.PP.more.com.climcha <- mm(FGN, more.com.climcha.resp.agree ~ Citizen.Religion.MusNon,
                                              id = ~ INTNR, h0 = 0.5)
Av.PP.more.com.climcha
#raise.fuel.price
Av.PP.raise.fuel.price <- mm(FGN, raise.fuel.price.resp.agree ~ Citizen.Religion.MusNon,
                                              id = ~ INTNR, h0 = 0.5)
Av.PP.raise.fuel.price
#immigrants.R.asset
Av.PP.immigrants.R.asset <- mm(FGN, immigrants.R.asset.resp.agree ~ Citizen.Religion.MusNon,
                                                id = ~ INTNR, h0 = 0.5)
Av.PP.immigrants.R.asset
#islam.not.restricted
Av.PP.islam.not.restricted <- mm(FGN, islam.not.restricted.resp.agree ~ Citizen.Religion.MusNon,
                                                  id = ~ INTNR, h0 = 0.5)
Av.PP.islam.not.restricted
#equal.pay.by.law
Av.PP.equal.pay.by.law <- mm(FGN, equal.pay.by.law.resp.agree ~ Citizen.Religion.MusNon,
                                              id = ~ INTNR, h0 = 0.5)
Av.PP.equal.pay.by.law
#homoco.may.adopt
Av.PP.homoco.may.adopt <- mm(FGN, homoco.may.adopt.resp.agree ~ Citizen.Religion.MusNon,
                                              id = ~ INTNR, h0 = 0.5)
Av.PP.homoco.may.adopt

#rbind
Av.PP <- rbind(Av.PP.tax.rich.higher, 
               Av.PP.raise.supp.unemp,
               Av.PP.more.com.climcha, 
               Av.PP.raise.fuel.price,
               Av.PP.immigrants.R.asset, 
               Av.PP.islam.not.restricted,
               Av.PP.equal.pay.by.law, 
               Av.PP.homoco.may.adopt)
Av.PP

#tax.rich.higher
Av.PP.tax.rich.higher.DF <- data.frame(
  names=Av.PP.tax.rich.higher$level,
  estimate=Av.PP.tax.rich.higher$estimate*100,
  conf.low=Av.PP.tax.rich.higher$lower*100,
  conf.high=Av.PP.tax.rich.higher$upper*100)

fig26.tax.rich.higher <- ggplot(data = Av.PP.tax.rich.higher.DF, 
                                 aes(x = estimate, y = reorder(names,desc(-names)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "The tax rate for the rich must be higher") + 
  xlim(10, 90) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig26.tax.rich.higher

#raise.supp.unemp
Av.PP.raise.supp.unemp.DF <- data.frame(
  names=Av.PP.raise.supp.unemp$level,
  estimate=Av.PP.raise.supp.unemp$estimate*100,
  conf.low=Av.PP.raise.supp.unemp$lower*100,
  conf.high=Av.PP.raise.supp.unemp$upper*100)

fig26.raise.supp.unemp <- ggplot(data = Av.PP.raise.supp.unemp.DF, 
                                 aes(x = estimate, y = reorder(names,desc(-names)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Our government should raise the support for the unemployed") + 
  xlim(10, 90) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig26.raise.supp.unemp

#more.com.climcha
Av.PP.more.com.climcha.DF <- data.frame(
  names=Av.PP.more.com.climcha$level,
  estimate=Av.PP.more.com.climcha$estimate*100,
  conf.low=Av.PP.more.com.climcha$lower*100,
  conf.high=Av.PP.more.com.climcha$upper*100)

fig26.more.com.climcha <- ggplot(data = Av.PP.more.com.climcha.DF, 
                                 aes(x = estimate, y = reorder(names,desc(-names)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Our government should do more to combat climate change than now") + 
  xlim(10, 90) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig26.more.com.climcha

#raise.fuel.price
Av.PP.raise.fuel.price.DF <- data.frame(
  names=Av.PP.raise.fuel.price$level,
  estimate=Av.PP.raise.fuel.price$estimate*100,
  conf.low=Av.PP.raise.fuel.price$lower*100,
  conf.high=Av.PP.raise.fuel.price$upper*100)

fig26.raise.fuel.price <- ggplot(data = Av.PP.raise.fuel.price.DF, 
                                 aes(x = estimate, y = reorder(names,desc(-names)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Our government needs to raise fuel prices") + 
  xlim(10, 90) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig26.raise.fuel.price

#immigrants.R.asset
Av.PP.immigrants.R.asset.DF <- data.frame(
  names=Av.PP.immigrants.R.asset$level,
  estimate=Av.PP.immigrants.R.asset$estimate*100,
  conf.low=Av.PP.immigrants.R.asset$lower*100,
  conf.high=Av.PP.immigrants.R.asset$upper*100)

fig26.immigrants.R.asset <- ggplot(data = Av.PP.immigrants.R.asset.DF, 
                                 aes(x = estimate, y = reorder(names,desc(-names)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Immigrants are an asset to our country") + 
  xlim(10, 90) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig26.immigrants.R.asset

#islam.not.restricted
Av.PP.islam.not.restricted.DF <- data.frame(
  names=Av.PP.islam.not.restricted$level,
  estimate=Av.PP.islam.not.restricted$estimate*100,
  conf.low=Av.PP.islam.not.restricted$lower*100,
  conf.high=Av.PP.islam.not.restricted$upper*100)

fig26.islam.not.restricted <- ggplot(data = Av.PP.islam.not.restricted.DF, 
                                 aes(x = estimate, y = reorder(names,desc(-names)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Islam should not be restricted by law") + 
  xlim(10, 90) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig26.islam.not.restricted

#equal.pay.by.law
Av.PP.equal.pay.by.law.DF <- data.frame(
  names=Av.PP.equal.pay.by.law$level,
  estimate=Av.PP.equal.pay.by.law$estimate*100,
  conf.low=Av.PP.equal.pay.by.law$lower*100,
  conf.high=Av.PP.equal.pay.by.law$upper*100)

fig26.equal.pay.by.law <- ggplot(data = Av.PP.equal.pay.by.law.DF, 
                                 aes(x = estimate, y = reorder(names,desc(-names)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") + 
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "That men and women receive equal pay for equal work should be regulated by law") + 
  xlim(10, 90) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig26.equal.pay.by.law

#homoco.may.adopt
Av.PP.homoco.may.adopt.DF <- data.frame(
  names=Av.PP.homoco.may.adopt$level,
  estimate=Av.PP.homoco.may.adopt$estimate*100,
  conf.low=Av.PP.homoco.may.adopt$lower*100,
  conf.high=Av.PP.homoco.may.adopt$upper*100)

fig26.homoco.may.adopt <- ggplot(data = Av.PP.homoco.may.adopt.DF, 
                                 aes(x = estimate, y = reorder(names,desc(-names)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high)) +
  theme_minimal() +
  ylab(" ") + 
  xlab("% of respondents agreeing with statement") + 
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Homosexual couples should be allowed to adopt children") + 
  xlim(10, 90) +
  geom_vline(xintercept = 50) + 
  theme(plot.title.position = "plot") 
#fig26.homoco.may.adopt

fig26 <- 
  fig26.tax.rich.higher/
  fig26.raise.supp.unemp/
  fig26.more.com.climcha/
  fig26.raise.fuel.price/
  fig26.immigrants.R.asset/
  fig26.islam.not.restricted/
  fig26.equal.pay.by.law/
  fig26.homoco.may.adopt +
  plot_annotation(title = 'Percentage of respondents agreeing that:',
                  #subtitle = ' ',
                  caption = "Error bars represent the 95% confidence interval. Respondents answered on a scale from 0 to 10 whether 
                  they agreed with the statement, respondents who answered 6-10 were counted as agreeing with the statement. 
                  Weighted on gender, education, region and urbanization.") 
fig26


#------------------------------------------#
#--- all figures in a row for RMarkdown ---#
#------------------------------------------#

#-----------------#
#--- main text ---#
#-----------------#
fig1
fig2
fig3
fig4

#----------------#
#--- appendix ---#
#----------------#
fig1.France
fig2.France
fig3.France
fig4.France

fig1.Germany
fig2.Germany
fig3.Germany
fig4.Germany

fig1.Netherlands
fig2.Netherlands
fig3.Netherlands
fig4.Netherlands

fig5
fig6
fig7
fig9fem
fig9mal
fig9femcit
fig9malcit
fig10
fig11
fig12
fig13
fig14
fig15
fig16
fig17
fig18
fig19
fig20
fig21
fig25.islam.not.restricted
fig25.equal.pay.by.law

#----------------------#
#--- extra appendix ---#
#----------------------#
fig22
fig23.tax.rich.higher
fig23.raise.supp.unemp
fig23.more.com.climcha
fig23.raise.fuel.price
fig23.immigrants.R.asset
fig23.islam.not.restricted
fig23.equal.pay.by.law
fig23.homoco.may.adopt
fig24
fig25.tax.rich.higher
fig25.raise.supp.unemp
fig25.more.com.climcha
fig25.raise.fuel.price
fig25.immigrants.R.asset
fig25.homoco.may.adopt
fig26

